Skip to content

Instantly share code, notes, and snippets.

@Wummer
Created June 27, 2018 09:54
Show Gist options
  • Save Wummer/29c32c48342130e20ca311260708b6fa to your computer and use it in GitHub Desktop.
Save Wummer/29c32c48342130e20ca311260708b6fa to your computer and use it in GitHub Desktop.
Bash script that binds anacoinda environment to a CUDA version. Requires the system environments ORIGINAL_LD_LIBRARY_PATH and LD_LIBRARY_PATH
#!/bin/bash
ENV=$1
CUDA=$2
# Create activation script
mkdir -p ~/anaconda3/envs/"$ENV"/etc/conda/activate.d
echo 'ORIGINAL_LD_LIBRARY_PATH='"$LD_LIBRARY_PATH" > ~/anaconda3/envs/$ENV/etc/conda/activate.d/activate.sh
echo 'export LD_LIBRARY_PATH=/usr/local/'"$CUDA"'/lib64' >> ~/anaconda3/envs/$ENV/etc/conda/activate.d/activate.sh
chmod +x ~/anaconda3/envs/"$ENV"/etc/conda/activate.d/activate.sh
#Create deactivation script
mkdir -p ~/anaconda3/envs/"$ENV"/etc/conda/deactivate.d
echo 'export LD_LIBRARY_PATH='"$ORIGINAL_LD_LIBRARY_PATH" > ~/anaconda3/envs/"$ENV"/etc/conda/deactivate.d/deactivate.sh
echo 'unset ORIGINAL_LD_LIBRARY_PATH' >> ~/anaconda3/envs/"$ENV"/etc/conda/deactivate.d/deactivate.sh
chmod +x ~/anaconda3/envs/"$ENV"/etc/conda/deactivate.d/deactivate.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment