Skip to content

Instantly share code, notes, and snippets.

@mauro-belgiovine
Created June 12, 2024 22:02
Show Gist options
  • Save mauro-belgiovine/6dd9b94ec1ff67784c8625bdab6e56f0 to your computer and use it in GitHub Desktop.
Save mauro-belgiovine/6dd9b94ec1ff67784c8625bdab6e56f0 to your computer and use it in GitHub Desktop.
This bash script exports all the CUDA libraries in Ubuntu/Linux environment for correct visibility of GPU devices. This is especially useful when using Tensorflow (> 3.15) in a Conda environment, which is not a default library location.
# HOW TO RUN IN TERMINAL:
# $ source tf_env_variables.sh
NVIDIA_DIR=$(dirname $(dirname $(python -c "import nvidia.cudnn;print(nvidia.cudnn.__file__)")))
for dir in $NVIDIA_DIR/*; do
if [ -d "$dir/lib" ]; then
export LD_LIBRARY_PATH="$dir/lib:$LD_LIBRARY_PATH"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment