Skip to content

Commit

Permalink
Reset LD_LIBRARY_PATH on deactivate (#1502)
Browse files Browse the repository at this point in the history
  • Loading branch information
roomrys authored Sep 15, 2023
1 parent c033f85 commit cf831b6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
10 changes: 5 additions & 5 deletions .conda/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ python setup.py install --single-version-externally-managed --record=record.txt

# Copy the activate scripts to $PREFIX/etc/conda/activate.d.
# This will allow them to be run on environment activation.
export CHANGE=activate

mkdir -p "${PREFIX}/etc/conda/${CHANGE}.d"
ls "${RECIPE_DIR}"
cp "${RECIPE_DIR}/${PKG_NAME}_${CHANGE}.sh" "${PREFIX}/etc/conda/${CHANGE}.d/${PKG_NAME}_${CHANGE}.sh"
for CHANGE in "activate" "deactivate"
do
mkdir -p "${PREFIX}/etc/conda/${CHANGE}.d"
cp "${RECIPE_DIR}/${PKG_NAME}_${CHANGE}.sh" "${PREFIX}/etc/conda/${CHANGE}.d/${PKG_NAME}_${CHANGE}.sh"
done
2 changes: 2 additions & 0 deletions .conda/sleap_activate.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/sh

# Remember the old library path for when we deactivate
export SLEAP_OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
# Help CUDA find GPUs!
export LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH
4 changes: 4 additions & 0 deletions .conda/sleap_deactivate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

# Reset to the old library path for when deactivating the environment
export LD_LIBRARY_PATH=$SLEAP_OLD_LD_LIBRARY_PATH
16 changes: 13 additions & 3 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,14 +343,15 @@ python -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU')
````{warning}
TensorFlow 2.7+ is currently failing to detect CUDA Toolkit and CuDNN on some systems (see [Issue thread](https://github.com/tensorflow/tensorflow/issues/52988)).
If you run into issues, try downgrading the TensorFlow 2.6:
If you run into issues, either try downgrading the TensorFlow 2.6:
```bash
pip install tensorflow==2.6.3
```
or follow the note below.
````
````{note}
If you are on Linux, have a NVIDIA GPU, and are having trouble utilizing your GPU:
If you are on Linux, have a NVIDIA GPU, but cannot detect your GPU:
```bash
W tensorflow/stream_executor/platform/default/dso_loader.cc:64 Could not load dynamic
Expand All @@ -368,10 +369,19 @@ and run the commands:
```bash
mkdir -p $CONDA_PREFIX/etc/conda/activate.d
echo '#!/bin/sh' >> $CONDA_PREFIX/etc/conda/activate.d/sleap_activate.sh
echo 'export SLEAP_OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH' >> $CONDA_PREFIX/etc/conda/activate.d/sleap_activate.sh
echo 'export LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH' >> $CONDA_PREFIX/etc/conda/activate.d/sleap_activate.sh
source $CONDA_PREFIX/etc/conda/activate.d/sleap_activate.sh
```
These commands only need to be run once and will subsequently run automatically upon activating your `sleap` environment.
This will set the environment variable `LD_LIBRARY_PATH` each time the environment is activated. The environment variable will remain set in the current terminal even if we deactivate the environment. Although not strictly necessary, if you would also like the environment variable to be reset to the original value when deactivating the environment, we can run the following commands:
```bash
mkdir -p $CONDA_PREFIX/etc/conda/deactivate.d
echo '#!/bin/sh' >> $CONDA_PREFIX/etc/conda/deactivate.d/sleap_deactivate.sh
echo 'export LD_LIBRARY_PATH=$SLEAP_OLD_LD_LIBRARY_PATH' >> $CONDA_PREFIX/etc/conda/deactivate.d/sleap_deactivate.sh
```
These commands only need to be run once and will subsequently run automatically upon [de]activating your `sleap` environment.
````
## Upgrading and uninstalling
Expand Down

0 comments on commit cf831b6

Please sign in to comment.