-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set LD_LIBRARY_PATH
on mamba activate
#1496
Conversation
WalkthroughThis pull request introduces changes to improve the package build instructions and environment activation for Linux and Windows users. It adopts Changes
TipsChat with CodeRabbit Bot (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 1
Files ignored due to filter (1)
- environment.yml
Files selected for processing (4)
- .conda/README.md (2 hunks)
- .conda/build.sh (1 hunks)
- .conda/sleap_activate.sh (1 hunks)
- docs/installation.md (1 hunks)
Files skipped from review due to trivial changes (3)
- .conda/README.md
- .conda/sleap_activate.sh
- docs/installation.md
Additional comments (Suppressed): 1
.conda/build.sh (1)
- 13-15: The installation of SLEAP itself remains unchanged and seems to be working as expected.
# 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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new block of code is responsible for copying the activation scripts to a specific directory. This will allow them to be run when the environment is activated. However, there's no error handling in case the copy operation fails. It would be beneficial to add some error checking here to ensure that the script has been copied successfully.
- cp "${RECIPE_DIR}/${PKG_NAME}_${CHANGE}.sh" "${PREFIX}/etc/conda/${CHANGE}.d/${PKG_NAME}_${CHANGE}.sh"
+ cp "${RECIPE_DIR}/${PKG_NAME}_${CHANGE}.sh" "${PREFIX}/etc/conda/${CHANGE}.d/${PKG_NAME}_${CHANGE}.sh" || {
+ echo "Failed to copy ${PKG_NAME}_${CHANGE}.sh";
+ exit 1;
+ }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The build just fails and gives us an error message if these lines end in failure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@roomrys While it's true that the build will fail and provide an error message if these lines end in failure, adding explicit error handling can still be beneficial. It allows you to control the error message that is displayed, making it more informative and specific to the operation that failed. This can help with troubleshooting and understanding exactly what went wrong.
For example, without explicit error handling, you might get a generic "No such file or directory" error. With explicit error handling, you can provide a message like "Failed to copy ${PKG_NAME}_${CHANGE}.sh", which immediately tells you that the script failed to copy.
Additionally, explicit error handling allows you to control the exit code of the script. This can be useful if other scripts or systems are relying on specific exit codes for certain types of failures.
Here's how you could modify the code to include explicit error handling:
cp "${RECIPE_DIR}/${PKG_NAME}_${CHANGE}.sh" "${PREFIX}/etc/conda/${CHANGE}.d/${PKG_NAME}_${CHANGE}.sh" || {
echo "Error: Failed to copy ${PKG_NAME}_${CHANGE}.sh to ${PREFIX}/etc/conda/${CHANGE}.d/";
exit 1;
}
This way, if the copy operation fails, the script will print a specific error message and then exit with a status of 1.
#!/bin/sh | ||
|
||
# Help CUDA find GPUs! | ||
export LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure this will work? I thought the cuda binaries were stored in the $CONDA_PREFIX/envs/{env_name}/lib
or something.
Like, one blocker for upgrading to newer tensorflow was that we couldn't dynamically set this since users would have different env names.
If it's really in $CONDA_PREFIX/lib
and it's not just hardcoding the path from the computer you built in (would Jinja do this?), then that's awesome and would allow us to move up to tf 2.9 I think!
If it doesn't work, then it might be ok to just include the extra line that people have to run in the install docs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The $CONDA_PREFIX
includes the environment name:
(nb4) talmolab@talmolab-01-ubuntu:~/sleap-estimates-animal-poses/pull-requests/sleap$ echo $CONDA_PREFIX
/home/talmolab/micromamba/envs/nb4
!!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's really in $CONDA_PREFIX/lib and it's not just hardcoding the path from the computer you built in (would Jinja do this?), ...
I think that might be the point of using cp
now that you mention it (instead of echo ... >> ...
).
Line 23 in 21339e9
cp "${RECIPE_DIR}/${PKG_NAME}_${CHANGE}.sh" "${PREFIX}/etc/conda/${CHANGE}.d/${PKG_NAME}_${CHANGE}.sh" |
...then that's awesome and would allow us to move up to tf 2.9 I think!
😨
environment.yml
Outdated
# 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly move to docs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also in the docs under GPU support. If you dislike it here I can remove?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description
Some Linux users have been unable to utilize the GPU. Modifying some installation instructions from
tensorflow
, this PR sets theLD_LIBRARY+PATH
onmamba activate
(if installing SLEAP via the conda package) and gives instructions for setting theLD_LIBRARY_PATH
manually (once and then automated onmamba activate
) for conda from source.Related:
Types of changes
Does this address any currently open issues?
Outside contributors checklist
Thank you for contributing to SLEAP!
❤️
Summary by CodeRabbit
conda
tomamba
for package management, improving the speed and reliability of environment creation and package installation.LD_LIBRARY_PATH
for Linux users with NVIDIA GPUs, resolving issues with GPU utilization.installation.md
to reflect the switch tomamba
and added guidance for Linux users with NVIDIA GPUs on how to set up their environment correctly.