Deeplabcut GPU env using Conda
This story discribes the steps of installing deeplabcut GPU version using Conda. The content is as follows:
- Installation Steps
2. Error Solve
Installation Steps
Installation of deeplabcut gpu version using conda should install the nvidia driver, conda, and deeplabcut sequentially
1.1 Install nvidia driver
1.2 install Conda
Note:
Conda is a package manager. Anaconda and Miniconda are the two primary distributions.
Anaconda include about a hundred packages of conda, numpy, scipy, ipython notebook et.al. Miniconda is a smaller alternative including just conda and its dependencies.
Installation Procedure (Official Guidance is here)
(1) download Anaconda (Linux, Python 3.7) here https://repo.anaconda.com/archive/Anaconda3-2019.03-Linux-x86_64.sh
(2) Enter the following to install Anaconda for Python 3.7:
$ bash ~/Downloads/Anaconda3–2019.03-Linux-x86_64.sh
# Include the bash command regardless of whether or not you are using Bash shell.# The installer prompts “Do you wish the installer to initialize Anaconda3 by running conda init?” Official guidance recommend “yes”. If you enter “no”, then conda will not modify your shell scripts at all. In order to initialize after the installation process is done, first run source <path to conda>/bin/activate and then run conda init.# don't allow base automatically shown in terminal
$ conda config --set auto_activate_base False
1.3. install deeplabcut
$ conda create -n tfgpu python=3.6
$ conda activate tfgpu(tfgpu)$ pip install deeplabcut
(tfgpu)$ pip install https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-18.04/wxPython-4.0.3-cp36-cp36m-linux_x86_64.whl
(tfgpu)$ conda install tensorflow-gpu==1.12
test:
(tfgpu)$ python
>>> import tensorflow
>>> import deeplabcutImportError:Something is wrong with the numpy installation. While importing we detected an older version of numpy in ['/home/lingling/anaconda3/envs/tfgpu/lib/python3.6/site-packages/numpy']. One method of fixing this is to repeatedly uninstall numpy until none is found, then reinstall this version.# uninstall numpy repeatedly until none is found
(tfgpu)$ conda remove numpy
(tfgpu)$ conda list numpy
(tfgpu)$ pip uninstall numpy
...
(tfgpu)$ conda install tensorflow-gpu=1.12 # reinstall tensorflow
Error Solve
- Could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR
Solve method: allow GPU memory growth, i.e add the following codes into your codes
import tensorflow as tf
from keras.backend.tensorflow_backend import set_session
config = tf.ConfigProto()
config.gpu_options.allow_growth = True # dynamically grow the memory used on the GPU
config.log_device_placement = True # to log device placement (on which device the operation ran)
# (nothing gets printed in Jupyter, only if you run it standalone)
sess = tf.Session(config=config)
set_session(sess) # set this TensorFlow session as the default session for Keras