Skip to content

Commit

Permalink
Merge branch 'Theano_updated' into github.SurfaceNet
Browse files Browse the repository at this point in the history
  • Loading branch information
mjiUST committed Mar 8, 2018
2 parents b8793ef + f1d79b4 commit 149f6e0
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 11 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ The [poster pdf](https://www.researchgate.net/publication/321126305_ICCV2017_Sur

1. install [Nvidia driver 375 + cuda 8.0 + cudnn v5.1](https://github.com/mjiUST/driver_cuda_cudnn)
2. install the conda environment by: `bash installEnv.sh`
* DON'T WORRY, conda will generate an isolated environment for SurfaceNet with python2.7, anaconda, theano, ... etc. That means all your libraries / packeges' version will not be affacted, at the same time the `~/.bashrc` file will not be changed.
* before you run, PLEASE change the CUDA/CUDNN path in the files:
- `./config/activate-cuda.sh` change the 1st line to your cuda path, e.g.: `export CUDA_ROOT=/usr/local/cuda`
- `./config/activate-cudnn.sh` change the 1st line to your cudnn path, e.g.: `export CUDNN_ROOT=/home/<your-user-name>/libs/cudnn`
3. download the network model to the folder "./inputs/SurfaceNet_models" from the Dropbox [folder](https://www.dropbox.com/sh/8xs0u57ikj4qfvr/AADRQFQyJfG3WfH7ZvpcWmMKa?dl=0)
4. if the conda environment has been installed, one can activate it by: `. activate SurfaceNet`; deactivate it by: `. deactivate`.
5. in terminal run: `python main.py`
Expand Down
7 changes: 7 additions & 0 deletions config/activate-cuda.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export CUDA_ROOT=/usr/local/cuda # set conda-env specific cuda path
export LD_LIBRARY_PATH_CUDA_BACKUP="$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH=$CUDA_ROOT/lib64:$LD_LIBRARY_PATH
export CPATH_CUDA_BACKUP="$CPATH"
export CPATH=$CUDA_ROOT/include:$CPATH
export LIBRARY_PATH_CUDA_BACKUP="$LIBRARY_PATH"
export LIBRARY_PATH=$CUDA_ROOT/lib64:$LIBRARY_PATH
7 changes: 7 additions & 0 deletions config/activate-cudnn.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export CUDNN_ROOT=/usr/local/cuda # set conda-env specific cudnn path, e.g.: /home/<your-user-name>/libs/cudnn
export LD_LIBRARY_PATH_CUDNN_BACKUP="$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH=$CUDNN_ROOT/lib64:$LD_LIBRARY_PATH
export CPATH_CUDNN_BACKUP="$CPATH"
export CPATH=$CUDNN_ROOT/include:$CPATH
export LIBRARY_PATH_CUDNN_BACKUP="$LIBRARY_PATH"
export LIBRARY_PATH=$CUDNN_ROOT/lib64:$LIBRARY_PATH
6 changes: 6 additions & 0 deletions config/deactivate-cuda.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH_PYGPU_CUDA_BACKUP"
unset LD_LIBRARY_PATH_PYGPU_CUDA_BACKUP
export CPATH="$CPATH_CUDA_BACKUP"
unset CPATH_CUDA_BACKUP
export LIBRARY_PATH="$LIBRARY_PATH_CUDA_BACKUP"
unset LIBRARY_PATH_CUDA_BACKUP
6 changes: 6 additions & 0 deletions config/deactivate-cudnn.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH_PYGPU_CUDNN_BACKUP"
unset LD_LIBRARY_PATH_PYGPU_CUDNN_BACKUP
export CPATH="$CPATH_CUDNN_BACKUP"
unset CPATH_CUDNN_BACKUP
export LIBRARY_PATH="$LIBRARY_PATH_CUDNN_BACKUP"
unset LIBRARY_PATH_CUDNN_BACKUP
21 changes: 10 additions & 11 deletions installEnv.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/bin/bash -evx

conda_env_name=SurfaceNet
cuda_root=/usr/local/cuda

# set -e # To exit the script as soon as one of the commands failed
cd ~/Downloads
Expand All @@ -16,29 +15,29 @@ else
. ~/.bashrc # to enable the conda command
fi

# config .bashrc, can change the CUDA_ROOT path
echo 'export CUDA_ROOT=$cuda_root' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=$CUDA_ROOT/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc
echo 'export CPATH=$CUDA_ROOT/include:$CPATH' >> ~/.bashrc
echo 'export LIBRARY_PATH=$CUDA_ROOT/lib64:$LIBRARY_PATH' >> ~/.bashrc
. ~/.bashrc # source before `source activate conda_env`
cd - # cd back to SurfaceNet work dir

# create new environment
if conda info --env | grep -w "$conda_env_name" >/dev/null; then
echo "The '$conda_env_name' conda env exists." # but the env will be visible even thoug the installation was terminated. In this case you should delete this conda env first.
else # if the env does not exist.
conda create -n $conda_env_name python=2.7 anaconda # install anaconda with the majority of the depandencies, (very large)
conda create -n $conda_env_name python=2.7 anaconda --yes # install anaconda with the majority of the depandencies, (very large)
fi
# assume the miniconda path is ~/miniconda2/
mkdir -p ~/miniconda2/envs/$conda_env_name/etc/conda/activate.d/
cp ./config/act* ~/miniconda2/envs/$conda_env_name/etc/conda/activate.d/ # before copy *PLEASE* change the CUDA/CUDNN path in the first line of these files accordingly
mkdir -p ~/miniconda2/envs/$conda_env_name/etc/conda/deactivate.d/
cp ./config/de* ~/miniconda2/envs/$conda_env_name/etc/conda/deactivate.d/
. activate $conda_env_name # seperate environment. Can use command `which python` to check the path of the local python/packeges

# install packeges
conda install theano pygpu --yes # http://www.deeplearning.net/software/theano/install_ubuntu.html#requirements-installation-through-conda-recommended
conda install -c rdonnelly theano -y # 0.9.0 version theano
pip install --upgrade https://github.com/Lasagne/Lasagne/archive/master.zip # http://lasagne.readthedocs.io/en/latest/user/installation.html#bleeding-edge-version
pip install plyfile progressbar

# config .theanorc,
if ls ~/.theanorc >/dev/null; then cp ~/.theanorc ~/.theanorc_backup; echo ".theanorc_backup was backed up"; fi
echo -e "[global] \nfloatX=float32 \ndevice=cuda \noptimizer=fast_run \n \nallow_gc=True \ngpuarray.preallocate=-1 \n \nnvcc.fastmath=True \n \n[cuda] \nroot=/usr/local/cuda" > ~/.theanorc
if ls ~/.theanorc >/dev/null; then cp ~/.theanorc ~/.theanorc_SurfaceNet_backup; echo ".theanorc_SurfaceNet_backup was backed up"; fi
echo -e "[global] \nfloatX=float32 \ndevice=cuda \noptimizer=fast_run \n \nallow_gc=True \ngpuarray.preallocate=-1 \n \nnvcc.fastmath=True \n" > ~/.theanorc

# test lasagne:
echo "Try to import lasagne. If there is no error, congratulations!"
Expand Down

0 comments on commit 149f6e0

Please sign in to comment.