@BIGBALLON
2017-10-12T09:01:28.000000Z
字数 4400
阅读 4467
The simple setup tutorial for deep learning beginner.
sudo apt-get updatesudo apt-get upgrade
sudo vi /etc/modprobe.d/disable-nouveau.conf//insert the following linesblacklist nouveauoptions nouveau modeset=0
sudo update-initramfs -usudo reboot
hit Ctrl+Alt+F1(tty1) and login, stop lightdm service & install dirver
sudo service lightdm stopsudo apt-get install nvidia-375sudo reboot
(optional)To install latest drivers add PPA:
sudo apt-get purge nvidia-*sudo add-apt-repository ppa:graphics-drivers/ppasudo apt-get updatesudo apt-get install nvidia-3xx
Then, you can use nvidia-smi to get the GPU info.
cuda_8.0.61_375.26_linux.run
cd Downloads/sudo chmod a+x cuda_8.0.61_375.26_linux.runsudo ./cuda_8.0.61_375.26_linux.run
Do you accept the previously read EULA?accept/decline/quit: acceptInstall NVIDIA Accelerated Graphics Driver for Linux-x86_64 375.26?(y)es/(n)o/(q)uit: noInstall the CUDA 8.0 Toolkit?(y)es/(n)o/(q)uit: yEnter Toolkit Location[ default is /usr/local/cuda-8.0 ]:Do you want to install a symbolic link at /usr/local/cuda?(y)es/(n)o/(q)uit: yInstall the CUDA 8.0 Samples?(y)es/(n)o/(q)uit: yEnter CUDA Samples Location[ default is /home/bg ]:
sudo vi ~/.bashrc//insert the following linesexport LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64export CUDA_HOME=/usr/local/cuda-8.0
source ~/.bashrc
cd /usr/local/cuda-8.0/samples/1_Utilities/deviceQuerysudo makesudo ./deviceQuery
cuDNN v6.0 for CUDA 8.0 in this tutorial)
cd Downloads/tar -zxvf cudnn-8.0-linux-x64-v6.0.tgzsudo cp cuda/include/cudnn.h /usr/local/cuda-8.0/includesudo cp cuda/lib64/libcudnn* /usr/local/cuda-8.0/lib64sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda-8.0/lib64/libcudnn*
virtualenv is a tool to create isolated Python environments.
We recommend you to use it instead of "native" pip.
sudo apt-get install python3-pip python3-dev python-virtualenv
virtualenv --system-site-packages -p python3 targetDirectory
where targetDirectory specifies the top of the virtualenv tree, our instructions assume that targetDirectory is ~/deeplearning, but you may choose any directory.
source ~/deeplearning/bin/activate
The preceding source command should change your prompt to the following:
(deeplearning) bg@bg-cgi:~$
(deeplearning) bg@bg-cgi:~$ easy_install -U pip
pip3 install http://download.pytorch.org/whl/cu80/torch-0.2.0.post3-cp35-cp35m-manylinux1_x86_64.whlpip3 install torchvision
Then, just test the Warm Up demo:
(deeplearning) bg@bg-cgi:~$ git clone https://github.com/2017-fall-DL-training-program/PyTorchWarmUp.git(deeplearning) bg@bg-cgi:~$ cd PyTorchWarmUp/(deeplearning) bg@bg-cgi:~/PyTorchWarmUp$ python3 CNN_MNIST_pytorch.py
After training(a few mins), you can see the following result:
Train Epoch: 20 [58496/60000 (97%)] Loss: 0.012621Train Epoch: 20 [58624/60000 (98%)] Loss: 0.011611Train Epoch: 20 [58752/60000 (98%)] Loss: 0.010518Train Epoch: 20 [58880/60000 (98%)] Loss: 0.008049Train Epoch: 20 [59008/60000 (98%)] Loss: 0.042140Train Epoch: 20 [59136/60000 (99%)] Loss: 0.002592Train Epoch: 20 [59264/60000 (99%)] Loss: 0.003716Train Epoch: 20 [59392/60000 (99%)] Loss: 0.006034Train Epoch: 20 [59520/60000 (99%)] Loss: 0.015948Train Epoch: 20 [59648/60000 (99%)] Loss: 0.005287Train Epoch: 20 [59776/60000 (100%)] Loss: 0.039094Train Epoch: 20 [44928/60000 (100%)] Loss: 0.005245Test set: Average loss: 0.0271, Accuracy: 9908/10000 (99%)
1 - 4: same as PyTorch
5) Issue one of the following commands to install TensorFlow(GPU) in the active virtualenv environment:
(deeplearning) bg@bg-cgi:~$ pip install --upgrade tensorflow # for Python 2.7(deeplearning) bg@bg-cgi:~$ pip3 install --upgrade tensorflow # for Python 3.n(deeplearning) bg@bg-cgi:~$ pip install --upgrade tensorflow-gpu # for Python 2.7 and GPU(deeplearning) bg@bg-cgi:~$ pip3 install --upgrade tensorflow-gpu # for Python 3.n and GPU
(deeplearning) bg@bg-cgi:~$ deactivate
To uninstall Pytorch(TensorFlow), simply remove the tree you created. For example:
rm -r ~/deeplearning