install tensorflow-gpu in docker on RHEL7
0. make sure that you have installed cuda
Check environment
- Verify you have a CUDA-capable GPU, run the command below and you will see the graphic info
1
lspci | grep -i nvidia
- Verify you have a supported version of Linux, check the version of Linux to install right version of CUDA
1
uname -m && cat /etc/*release
- Verify the system has gcc Installed. Or install gcc firstly before installing CUDA.
1
gcc --version
Install steps (by runfile)
- (optional)Install kernel headers and development packages for the currently running kernel. If you have installed these packages, you could skip this step.
1
sudo yum install kernel-devel-(uname -r)
- Disable the Nouveau drivers
a. Create a file at /etc/modprobe.d/blacklist-nouveau.conf with below contentsb. Regenerate the kernel initramfs1
2blacklist nouveau
options nouveau modeset=01
sudo dracut –force
- (optional)Reboot to the graphical interface, and change to command interface with command sudo init 3. This step is to install graphic card driver.
- Run the installer (runfile) with command sudo sh cuda_
_linux.run. If you choose to install graphic card driver, you must run step 3 first. - Create an xorg.conf file to use the NVIDIA GPU for display:
1
sudo nvidia-xconfig
- Reboot the system to load the graphical interface
- Set up the development environment by modifying the PATH and LD_LIBRARY_PATH variables
1
2export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} - Run the nbody sample to make sure whether CUDA works or not.
1
2
3cd /usr/local/cuda/samples/5_Simulations/nbody
sudo make
./nbody
1. install nvidia-docker
Refer to https://github.com/nvidia/nvidia-docker/wiki/Installation-(version-2.0)
2. pull image from tensorflow/tensorflow
1 |
|
3. run docker container
1 |
|
4. check if it works or not
1 |
|
5. reference
[1] https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html
[2] https://github.com/nvidia/nvidia-docker/wiki
[3] https://www.tensorflow.org/install/docker
附: docker-compose.yml1
2
3
4
5
6
7version '2.3'
services:
tensorflow-gpu:
image: tensorflow/tensorflow:latest-gpu-py3
runtime: nvidia
environment:
- NVIDIA_VISIBLE_DEVICES=all
install tensorflow-gpu in docker on RHEL7
https://r-future.github.io/post/intall-tensorflow-gpu-in-docker/