Skip to content

Commit

Permalink
singularity + cuda10
Browse files Browse the repository at this point in the history
  • Loading branch information
shubham-goel committed Feb 24, 2021
1 parent ee42add commit 6d7269a
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 5 deletions.
80 changes: 80 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# conda create -n shaperecon_cuda102 python=3.6
# conda activate shaperecon_cuda102

# export CUDA_HOME=/usr/local/cuda-10.2
# export PATH=/usr/local/cuda-10.2/bin:$PATH
# export LD_LIBRARY_PATH=/usr/local/cuda-10.2/lib64:$LD_LIBRARY_PATH

# conda install -c pytorch torchvision=0.2.1 cudatoolkit=10.2
# conda install -c conda-forge \
# pandas=0.23.4 \
# tqdm=4.28.1 \
# scikit-image=0.14.0 \
# numba=0.41.0 \
# opencv=3.4.2 \
# tensorflow=1.5.1 \
# trimesh=2.35.47 \
# rtree=0.8.3 \
# scikit-learn=0.20.1


######### This installation needs to be done only once - START ###########

# Clone Genre, or copy from /home/shubham/code/GenRe-ShapeHD
git clone git@github.com:shubham-goel/GenRe-ShapeHD.git $GENRE_ROOT
cd $GENRE_ROOT
GENRE_ROOT=`pwd`
GENRE_ROOT=/home/shubham/code/GenRe-ShapeHD

# Using singularity container for installing pytorch0.4.1 w/ cuda10
sandbox=/home/$USER/sandbox/genre2
singularity build --fakeroot --sandbox $sandbox docker://nvcr.io/nvidia/pytorch:18.09-py3
singularity shell --nv --fakeroot --writable $sandbox
mkdir /genre
exit

# Get gpu
srun --gres=gpu:1 --pty bash

# Open singularity
singularity shell --nv --fakeroot \
--bind $GENRE_ROOT:/genre \
--writable $sandbox
cd /genre

# pytorch0.4.1 + cuda10.0 should be available already
python -c 'import torch; print(torch.__version__, torch.version.cuda, torch.cuda.is_available());'

# install genre dependencies
pip install --upgrade pip
pip install \
scikit-image==0.14.0 \
opencv-python==3.4.2.17 \
tensorflow==1.5.1 \
rtree==0.8.3 \
trimesh[all]==2.35.47 \
scikit-learn==0.20.1
pip install llvmlite==0.32.1 numba==0.41.0

# install genre cuda kernels
./clean_toolbox_build.sh
./build_toolbox.sh

# Exit singularity
exit
# release gpu
exit

# Test
srun --gres=gpu:1 singularity exec --nv \
--bind $GENRE_ROOT:/genre \
$sandbox bash -c "cd /genre && ./scripts/test_genre.sh 0"

# Save an image to run quickly
singularity build --fakeroot ~/genre.sif $sandbox
######### This installation needs to be done only once - END ###########

GENRE_ROOT=/home/shubham/code/GenRe-ShapeHD
srun --gres=gpu:1 singularity exec --nv \
--bind $GENRE_ROOT:/genre \
~/genre.sif bash -c "cd /genre && ./scripts/test_genre.sh 0"
4 changes: 2 additions & 2 deletions scripts/test_genre.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ shift # shift the remaining arguments

set -e

source activate shaperecon
# source activate shaperecon

python 'test.py' \
--net genre_full_model \
Expand All @@ -32,4 +32,4 @@ python 'test.py' \
--gpu "$gpu" \
$*

source deactivate
# source deactivate
4 changes: 3 additions & 1 deletion toolbox/calc_prob/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ echo "Check 'http://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html' f
# Titan X (Pascal): 61
# GTX 1080: 61
# Titan Xp: 61
# GTX 2080: 75

TORCH=$(python -c "import os; import torch; print(os.path.dirname(torch.__file__))")
HAS_CUDA=$(python -c "import torch; print(torch.cuda.is_available())")
Expand All @@ -22,10 +23,11 @@ if [ "$HAS_CUDA" == "True" ]; then
fi
cd calc_prob/src
HERE=$(pwd -P)
cmd="nvcc -c -o calc_prob_kernel.cu.o calc_prob_kernel.cu -x cu -Xcompiler -fPIC -I ${TORCH}/lib/include -I ${TORCH}/lib/include/TH -I ${TORCH}/lib/include/THC -I ${HERE} \
cmd="nvcc -c -std=c++11 -o calc_prob_kernel.cu.o calc_prob_kernel.cu -x cu -Xcompiler -fPIC -I ${TORCH}/lib/include -I ${TORCH}/lib/include/TH -I ${TORCH}/lib/include/THC -I ${HERE} \
-gencode arch=compute_30,code=sm_30 \
-gencode arch=compute_35,code=sm_35 \
-gencode arch=compute_52,code=sm_52 \
-gencode arch=compute_75,code=sm_75 \
-gencode arch=compute_61,code=sm_61 "
echo "$cmd"
eval "$cmd"
Expand Down
4 changes: 3 additions & 1 deletion toolbox/cam_bp/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ echo "Check 'http://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html' f
# GTX Titan X: 52
# Titan X (Pascal): 61
# GTX 1080: 61
# GTX 2080: 75
# Titan Xp: 61

TORCH=$(python -c "import os; import torch; print(os.path.dirname(torch.__file__))")
Expand All @@ -22,10 +23,11 @@ if [ "$HAS_CUDA" == "True" ]; then
fi
cd cam_bp/src
HERE=$(pwd -P)
cmd="nvcc -c -o back_projection_kernel.cu.o back_projection_kernel.cu -x cu -Xcompiler -fPIC -I ${TORCH}/lib/include/TH -I ${TORCH}/lib/include -I ${TORCH}/lib/include/THC -I ${HERE} -I ${TORCH}/lib/include\
cmd="nvcc -c -std=c++11 -o back_projection_kernel.cu.o back_projection_kernel.cu -x cu -Xcompiler -fPIC -I ${TORCH}/lib/include/TH -I ${TORCH}/lib/include -I ${TORCH}/lib/include/THC -I ${HERE} -I ${TORCH}/lib/include\
-gencode arch=compute_30,code=sm_30 \
-gencode arch=compute_35,code=sm_35 \
-gencode arch=compute_52,code=sm_52 \
-gencode arch=compute_75,code=sm_75 \
-gencode arch=compute_61,code=sm_61"
echo "$cmd"
eval "$cmd"
Expand Down
4 changes: 3 additions & 1 deletion toolbox/nndistance/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ echo "Check 'http://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html' f
# GTX Titan X: 52
# Titan X (Pascal): 61
# GTX 1080: 61
# GTX 2080: 75
# Titan Xp: 61
# Titan V: 70

Expand All @@ -31,10 +32,11 @@ if [ "$HAS_CUDA" == "True" ]; then
fi
cd src
HERE=$(pwd -P)
cmd="nvcc -c -o nnd_cuda.cu.o nnd_cuda.cu -x cu -Xcompiler -fPIC -I ${TORCH}/lib/include/TH -I ${TORCH}/lib/include/THC -I ${HERE} -I ${TORCH}/lib/include\
cmd="nvcc -c -std=c++11 -o nnd_cuda.cu.o nnd_cuda.cu -x cu -Xcompiler -fPIC -I ${TORCH}/lib/include/TH -I ${TORCH}/lib/include/THC -I ${HERE} -I ${TORCH}/lib/include\
-gencode arch=compute_30,code=sm_30 \
-gencode arch=compute_35,code=sm_35 \
-gencode arch=compute_52,code=sm_52 \
-gencode arch=compute_75,code=sm_75 \
-gencode arch=compute_61,code=sm_61"
echo "$cmd"
eval "$cmd"
Expand Down

0 comments on commit 6d7269a

Please sign in to comment.