From c24b9cb83e74283b558afd2f2fdc9ceb05a8a57d Mon Sep 17 00:00:00 2001 From: roomrys Date: Tue, 12 Sep 2023 12:06:56 -0700 Subject: [PATCH 1/3] Set LD_LIBRARY_PATH on mamba activate --- .conda/README.md | 4 ++-- .conda/build.sh | 10 +++++++++- .conda/sleap_activate.sh | 4 ++++ docs/installation.md | 25 +++++++++++++++++++++++++ environment.yml | 13 +++++++++++++ 5 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 .conda/sleap_activate.sh diff --git a/.conda/README.md b/.conda/README.md index 65fadd36e..71a49d7f1 100644 --- a/.conda/README.md +++ b/.conda/README.md @@ -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: @@ -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. diff --git a/.conda/build.sh b/.conda/build.sh index 620cd127a..1ea1d4df0 100644 --- a/.conda/build.sh +++ b/.conda/build.sh @@ -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 \ No newline at end of file +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" diff --git a/.conda/sleap_activate.sh b/.conda/sleap_activate.sh new file mode 100644 index 000000000..feebadd60 --- /dev/null +++ b/.conda/sleap_activate.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Help CUDA find GPUs! +export LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH \ No newline at end of file diff --git a/docs/installation.md b/docs/installation.md index ee9dad1ea..bc1e05c43 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -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/libcudart_activate.sh +echo 'export LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH' >> $CONDA_PREFIX/etc/conda/activate.d/libcudart_activate.sh +source $CONDA_PREFIX/etc/conda/activate.d/libcudart_activate.sh +``` +These commands only need to be run once and will subsequently run autimatically 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. diff --git a/environment.yml b/environment.yml index 9f9ff903d..e186df43f 100644 --- a/environment.yml +++ b/environment.yml @@ -46,3 +46,16 @@ dependencies: - pip: - "--editable=.[conda_dev]" + +# If you are on Linux, have a NVIDIA GPU, and are getting the warning: + +# 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 and run the commands: + +# mkdir -p $CONDA_PREFIX/etc/conda/activate.d +# echo '#!/bin/sh' >> $CONDA_PREFIX/etc/conda/activate.d/libcudart_activate.sh +# echo 'export LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH' >> $CONDA_PREFIX/etc/conda/activate.d/libcudart_activate.sh +# source $CONDA_PREFIX/etc/conda/activate.d/libcudart_activate.sh \ No newline at end of file From 21339e9062fc8a065662383ccb4b06513d84e950 Mon Sep 17 00:00:00 2001 From: roomrys Date: Tue, 12 Sep 2023 13:09:05 -0700 Subject: [PATCH 2/3] Rename libcudart_activate.sh to sleap_activate.sh in docs --- docs/installation.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/installation.md b/docs/installation.md index bc1e05c43..c311f0851 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -367,11 +367,11 @@ 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/libcudart_activate.sh -echo 'export LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH' >> $CONDA_PREFIX/etc/conda/activate.d/libcudart_activate.sh -source $CONDA_PREFIX/etc/conda/activate.d/libcudart_activate.sh +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 autimatically upon activating your `sleap` environment. +These commands only need to be run once and will subsequently run automatically upon activating your `sleap` environment. ```` ## Upgrading and uninstalling From 94efb5f9e0f64ef3cec079cd1cdc7cda3973127a Mon Sep 17 00:00:00 2001 From: roomrys Date: Tue, 12 Sep 2023 16:22:49 -0700 Subject: [PATCH 3/3] Remove comments from environment.yml --- environment.yml | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/environment.yml b/environment.yml index e186df43f..67ed39d01 100644 --- a/environment.yml +++ b/environment.yml @@ -46,16 +46,4 @@ dependencies: - pip: - "--editable=.[conda_dev]" - -# If you are on Linux, have a NVIDIA GPU, and are getting the warning: - -# 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 and run the commands: - -# mkdir -p $CONDA_PREFIX/etc/conda/activate.d -# echo '#!/bin/sh' >> $CONDA_PREFIX/etc/conda/activate.d/libcudart_activate.sh -# echo 'export LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH' >> $CONDA_PREFIX/etc/conda/activate.d/libcudart_activate.sh -# source $CONDA_PREFIX/etc/conda/activate.d/libcudart_activate.sh \ No newline at end of file + \ No newline at end of file