Skip to content

Instantly share code, notes, and snippets.

@jerrylususu
Last active July 3, 2021 14:05
Show Gist options
  • Save jerrylususu/f049045d5c6a681fc1204708ea5296a9 to your computer and use it in GitHub Desktop.
Save jerrylususu/f049045d5c6a681fc1204708ea5296a9 to your computer and use it in GitHub Desktop.
Install tensorflow-gpu 2.5.0 with conda (2021/7/3)
# as of writing (2021/7/3), here is a list of the version of latest packages (arch=linux64):
# tensorflow-gpu: 2.4.0 (anaconda)
# cudnn: 8.2.1 (conda-forge)
# cudatoolkit: 11.0.221 (anaconda)
# step 1: create new conda environment, install python & cudatoolkit
conda create -n tf_25_new python=3.8 cudatoolkit=11.0.221
conda activate tf_25_new
# step 2: install cudann from conda forge
conda install -c conda-forge cudnn=8.2.1
# step 3: install tensorflow-gpu from pip
# Pillow version is specified to avoid a bug
# see https://github.com/tensorflow/tensorflow/issues/46840#issuecomment-872946341
pip3 install tensorflow-gpu==2.5.0 Pillow==8.2.0
# step 4: make a file link to fix a bug when testing GPU existance
# see https://github.com/tensorflow/tensorflow/issues/43947#issuecomment-722019317
# replace `miniconda` with `anaconda` if you use anaconda instead of miniconda
cd /home/<your_user_name>/miniconda3/envs/tf_25_new/lib
ln -s libcusolver.so.10 libcusolver.so.11
# now the installation has finished
# step 5: test
# if you see a list with your GPU in it, then that's a success
# NOTE: the main issue here is LD_LIBRARY_PATH env var
# to use it outside conda, run `export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/<your_user_name>/miniconda3/envs/tf_25_new/lib`
python
import tensorflow as tf
tf.config.list_physical_devices('GPU')
# success output example
# ---------------------------------
# (tf_25_new) $ python
# Python 3.8.10 (default, Jun 4 2021, 15:09:15)
# [GCC 7.5.0] :: Anaconda, Inc. on linux
# Type "help", "copyright", "credits" or "license" for more information.
# >>> import tensorflow as tf
# 2021-07-03 16:42:38.836952: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library libcudart.so.11.0
# >>> tf.config.list_physical_devices('GPU')
# 2021-07-03 16:42:47.287324: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library libcuda.so.1
# 2021-07-03 16:42:47.361312: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1733] Found device 0 with properties:
# pciBusID: 0000:1a:00.0 name: NVIDIA GeForce RTX 2080 Ti computeCapability: 7.5
# coreClock: 1.545GHz coreCount: 68 deviceMemorySize: 10.76GiB deviceMemoryBandwidth: 573.69GiB/s
# 2021-07-03 16:42:47.361417: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library libcudart.so.11.0
# 2021-07-03 16:42:47.368472: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library libcublas.so.11
# 2021-07-03 16:42:47.368578: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library libcublasLt.so.11
# 2021-07-03 16:42:47.371829: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library libcufft.so.10
# 2021-07-03 16:42:47.373032: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library libcurand.so.10
# 2021-07-03 16:42:47.379682: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library libcusolver.so.11
# 2021-07-03 16:42:47.381517: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library libcusparse.so.11
# 2021-07-03 16:42:47.382556: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library libcudnn.so.8
# 2021-07-03 16:42:47.386105: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1871] Adding visible gpu devices: 0
# [PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment