Skip to content

Commit

Permalink
Set LD_LIBRARY_PATH on mamba activate (#1496)
Browse files Browse the repository at this point in the history
* Set LD_LIBRARY_PATH on mamba activate

* Rename libcudart_activate.sh to sleap_activate.sh in docs

* Remove comments from environment.yml
  • Loading branch information
roomrys committed Sep 12, 2023
1 parent b8a37c4 commit cdf8cba
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .conda/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ This folder defines the conda package build for Linux and Windows. There are run
To build, first go to the base repo directory and install the build environment:

```
conda env create -f environment_build.yml -n sleap_build && conda activate sleap_build
mamba env create -f environment_build.yml -n sleap_build && conda activate sleap_build
```

And finally, run the build command pointing to this directory:
Expand All @@ -15,7 +15,7 @@ conda build .conda --output-folder build -c conda-forge -c nvidia -c https://con
To install the local package:

```
conda create -n sleap_0 -c conda-forge -c nvidia -c ./build -c https://conda.anaconda.org/sleap/ -c anaconda sleap=x.x.x
mamba create -n sleap_0 -c conda-forge -c nvidia -c ./build -c https://conda.anaconda.org/sleap/ -c anaconda sleap=x.x.x
```

replacing x.x.x with the version of SLEAP that you just built.
10 changes: 9 additions & 1 deletion .conda/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,12 @@ pip install --no-cache-dir -r ./requirements.txt

# Install sleap itself. This does not install the requirements, but will list which
# requirements are missing (see "install_requires") when user attempts to install.
python setup.py install --single-version-externally-managed --record=record.txt
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"
4 changes: 4 additions & 0 deletions .conda/sleap_activate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

# Help CUDA find GPUs!
export LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH
25 changes: 25 additions & 0 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,31 @@ pip install tensorflow==2.6.3
```
````
````{note}
If you are on Linux, have a NVIDIA GPU, and are having trouble utilizing your GPU:
```bash
W tensorflow/stream_executor/platform/default/dso_loader.cc:64 Could not load dynamic
library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object
file: No such file or directory
```
then activate the environment:
```bash
mamba activate sleap
```
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 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.
````
## Upgrading and uninstalling
We **strongly recommend** installing SLEAP in a fresh environment when updating. This is because dependency versions might change, and depending on the state of your previous environment, directly updating might break compatibility with some of them.
Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@ dependencies:

- pip:
- "--editable=.[conda_dev]"

0 comments on commit cdf8cba

Please sign in to comment.