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
Can we use Conda environment for installing torch? #341
Comments
Hi @issactoast Currently we rely on LibTorch 1.5 which does not support CUDA 11.0, but the next version of torch will use LibTorch 1.7, so CUDA 11.0 will be supported. Just to make sure I understand... are you suggesting that you should be able to |
Hello @dfalbel Thanks for the quick response. Either way could solve the problem now, but enabling |
OK! I'll need some help from the community on that. I have never submitted R packages to |
Building conda packages from CRAN is easy, basic instructions are at https://docs.conda.io/projects/conda-build/en/latest/user-guide/tutorials/build-r-pkgs.html I built a conda package and uploaded to https://anaconda.org/izahn/r-torch This package works well on my Arch Linux system, but fails on RHEL 7 with this error message:
The conda installation has a copy of |
That's awesome @izahn ! Thanks! Doesn't this: |
@dfalbel the conda build system includes glibc (or at least |
have you tried setting LD_LIBRARY_PATH? |
I tried setting LD_LIBRARY_PATH, but that caused other errors during the build process itself (even before the install_torch() part). This seems to be where conda packaging gets more complicated. The conda build system uses a sysroot, as described in https://docs.conda.io/projects/conda-build/en/latest/resources/define-metadata.html#host and conda/conda-build#3696. I'm a bit out of my depth here, but as far as I can figure building the torch R package uses the conda sysroot, but install_torch doesn't know about it and tries to use host system libraries. Is it possible to build the torch libraries instead of installing the pre-built ones with |
Yes, you can build libtorch with instructions here: https://github.com/pytorch/pytorch/blob/master/docs/libtorch.rst#building-libtorch-using-cmake And lantern (the C interface to libtorch that we use in the R package) here: https://github.com/mlverse/torch/blob/master/tools/buildlantern.R Maybe you could also point to the the lib included in the torch conda package ( |
OK, I've made some progress on this front and submitted a conda package recipe at conda-forge/staged-recipes#13992 Setting up CUDA packages for conda is more complicated, so this is CPU-only for now. I do hope to add CUDA support in the future. Finally, I'd love some help maintaining the conda package, let me know if you are interested and I'll add you to the maintainers list. |
Further update -- I've given up for now on packaging torch for conda. Fundamentally conda doesn't want repackaged binaries, and the torch package doesn't make it easy to install without repackaged binaries., I fought with it for a while, but kept ending up with
or similar. |
Hi @izahn , Thanks for your efforts and sorry it didn't work!
What should we change in the R package to solve this? Is it related to separated compilation steps for libtorch and liblantern? we could perhaps download the binaries in this script: and patch the .Rbuildignore to allow the binaries to be included in the built package. Is it possible to see the logs for the builds? |
I'm still relatively new to conda packaging and not totally sure how it works. The package building process definitely flags the pre-built libraries though. I tried telling it to ignore them in https://github.com/conda-forge/staged-recipes/pull/13992/files#diff-f21c0b2e0f37c9ea8dac5100f7bcecab20c39783571405ff1d7425d4beea380aR22, which kind of works. My (admittedly limited) understanding is that conda-forge wants to build everything so that everything is built with the same toolchain.
Maybe, I don't know if that will help or not.
There are some older logs (probably not helpful, from before I realized I actually needed at least I re-started the CI so you can see the result of my latest effort over at https://dev.azure.com/conda-forge/feedstock-builds/_build/results?buildId=279239&view=logs&j=6f142865-96c3-535c-b7ea-873d86b887bd&t=22b0682d-ab9e-55d7-9c79-49f3c3ba4823 |
Close this. For future reference, you can use a torch with GPU support on WSL2 ubuntu 18.04. |
I am on Windows10 using WSL2, which requires CUDA 11.0.
I can install PyTorch using Conda environment and using WSL2 at the same time but can't use the torch in R. I think this lack of ability to combine virtual env for the torch in R blowing tons of possible users for the package.
The text was updated successfully, but these errors were encountered: