TheoreticalEcology / s-jSDM

Scalable joint species distribution modeling
https://cran.r-project.org/web/packages/sjSDM/index.html
GNU General Public License v3.0
67 stars 14 forks source link

PyTorch not loading #107

Closed AndrewCSlater closed 1 year ago

AndrewCSlater commented 1 year ago

I have installed & run sjSDM on the cpu but can't get it to work on GPU. Followed the help with install vignette and am posting the output of r sjSDM::install_diagnostic() below. I'm not a techie so need really basic advice please.

      name                                                                       python

1 base C:\Users\acs_a\AppData\Local\r-miniconda/python.exe 2 r-reticulate C:\Users\acs_a\AppData\Local\r-miniconda\envs\r-reticulate/python.exe 3 r-sjsdm C:\Users\acs_a\AppData\Local\r-miniconda\envs\r-sjsdm/python.exe 4 anaconda3 C:\Users\acs_a\anaconda3/python.exe 5 r-sjsdm C:\Users\acs_a\anaconda3\envs\r-sjsdm/python.exe

ENV: base

torch:

packages in environment at C:\Users\acs_a\AppData\Local\R-MINI~1:

#

Name Version Build Channel

numpy:

packages in environment at C:\Users\acs_a\AppData\Local\R-MINI~1:

#

Name Version Build Channel

ENV: r-reticulate

torch:

packages in environment at C:\Users\acs_a\AppData\Local\R-MINI~1\envs\r-reticulate:

#

Name Version Build Channel

pytorch 1.9.1 py3.6_cpu_0 [cpuonly] pytorch pytorch-mutex 1.0 cuda pytorch pytorch-ranger 0.1.1 pypi_0 pypi torch-optimizer 0.3.0 pypi_0 pypi torchaudio 0.9.1 py36 pytorch torchvision 0.2.2 py_3 pytorch

numpy:

packages in environment at C:\Users\acs_a\AppData\Local\R-MINI~1\envs\r-reticulate:

#

Name Version Build Channel

numpy 1.19.5 py36h4b40d73_2 conda-forge

ENV: r-sjsdm

torch:

packages in environment at C:\Users\acs_a\AppData\Local\R-MINI~1\envs\r-sjsdm:

#

Name Version Build Channel

pytorch 1.12.1 py3.7_cpu_0 pytorch pytorch-mutex 1.0 cpu pytorch pytorch-ranger 0.1.1 pypi_0 pypi torch-optimizer 0.3.0 pypi_0 pypi torchaudio 0.12.1 py37_cpu pytorch torchvision 0.13.1 py37_cpu pytorch

numpy:

packages in environment at C:\Users\acs_a\AppData\Local\R-MINI~1\envs\r-sjsdm:

#

Name Version Build Channel

numpy 1.21.6 pypi_0 pypi numpy-base 1.21.5 py37hca35cd5_3

ENV: anaconda3

torch:

EnvironmentLocationNotFound: Not a conda environment: C:\Users\acs_a\AppData\Local\R-MINI~1\envs\anaconda3

numpy:

EnvironmentLocationNotFound: Not a conda environment: C:\Users\acs_a\AppData\Local\R-MINI~1\envs\anaconda3

ENV: r-sjsdm

torch:

packages in environment at C:\Users\acs_a\AppData\Local\R-MINI~1\envs\r-sjsdm:

#

Name Version Build Channel

pytorch 1.12.1 py3.7_cpu_0 pytorch pytorch-mutex 1.0 cpu pytorch pytorch-ranger 0.1.1 pypi_0 pypi torch-optimizer 0.3.0 pypi_0 pypi torchaudio 0.12.1 py37_cpu pytorch torchvision 0.13.1 py37_cpu pytorch

numpy:

packages in environment at C:\Users\acs_a\AppData\Local\R-MINI~1\envs\r-sjsdm:

#

Name Version Build Channel

numpy 1.21.6 pypi_0 pypi numpy-base 1.21.5 py37hca35cd5_3

python: C:/Users/acs_a/anaconda3/python.exe libpython: C:/Users/acs_a/anaconda3/python39.dll pythonhome: C:/Users/acs_a/anaconda3 version: 3.9.12 (main, Apr 4 2022, 05:22:27) [MSC v.1916 64 bit (AMD64)] Architecture: 64bit numpy: C:/Users/acs_a/anaconda3/Lib/site-packages/numpy numpy_version: 1.21.5 torch: [NOT FOUND]

NOTE: Python version was forced by RETICULATE_PYTHON

 active environment : C:/Users/acs_a/anaconda3
active env location : C:/Users/acs_a/anaconda3
   user config file : C:\Users\acs_a\.condarc

populated config files : C:\Users\acs_a.condarc conda version : 4.10.3 conda-build version : not installed python version : 3.9.5.final.0 virtual packages : cuda=11.8=0 win=0=0 __archspec=1=x86_64 base environment : C:\Users\acs_a\AppData\Local\R-MINI~1 (writable) conda av data dir : C:\Users\acs_a\AppData\Local\R-MINI~1\etc\conda conda av metadata url : None channel URLs : https://repo.anaconda.com/pkgs/main/win-64 https://repo.anaconda.com/pkgs/main/noarch https://repo.anaconda.com/pkgs/r/win-64 https://repo.anaconda.com/pkgs/r/noarch https://repo.anaconda.com/pkgs/msys2/win-64 https://repo.anaconda.com/pkgs/msys2/noarch package cache : C:\Users\acs_a\AppData\Local\R-MINI~1\pkgs C:\Users\acs_a.conda\pkgs C:\Users\acs_a\AppData\Local\conda\conda\pkgs envs directories : C:\Users\acs_a\AppData\Local\R-MINI~1\envs C:\Users\acs_a.conda\envs C:\Users\acs_a\AppData\Local\conda\conda\envs platform : win-64 user-agent : conda/4.10.3 requests/2.26.0 CPython/3.9.5 Windows/10 Windows/10.0.19044 administrator : False netrc file : None offline mode : False

MaximilianPi commented 1 year ago

Hi @AndrewCSlater, just to confirm, you have a NVIDIA GPU, right? Because other GPUs are not supported (Intel GPUs, Mac m1/m2 GPUs, AMD GPUs, etc.).

If you have a NVIDIA GPU, try the following steps (run from within R):

restart RStudio

reticulate::conda_remove('r-reticulate')
reticulate::conda_remove('r-sjsdm')
reticulate::conda_create('r-sjsdm', python_version='3.9')
reticulate::conda_install('r-sjsdm',packages = c("pytorch", "torchvision" ,"torchaudio", "cudatoolkit=11.3", "-c", "pytorch"))
reticulate::conda_install('r-sjsdm',packages = c("pyro-ppl", "torch_optimizer", "madgrad"), pip=TRUE)

restart RStudio

AndrewCSlater commented 1 year ago

Hi Max, I can't remember which one, but yes I definitely have an NVIDEA graphics card.I have zero experience with Python, or JSDM's etc, I'm far more a field ecologist and feel a bit out of my depth in this area, so any help aimed at non techies would really be greatly appreciated. Thanks a million for your time!CheersAndrew

On Thursday, 13 October 2022 at 07:52:48 BST, MaximilianPi ***@***.***> wrote:  

Hi @AndrewCSlater, just to confirm, you have a NVIDIA GPU, right? Because other GPUs are not supported (Intel GPUs, Mac m1/m2 GPUs, AMD GPUs, etc.)

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

MaximilianPi commented 1 year ago

Don't worry, no technical knowledge is required. Try the steps above and let's see if it works.

AndrewCSlater commented 1 year ago

OK I ran the code as above, but when I reopened R Studio & ran sjSDM::install_sjSDM(), I went through the process and came back with the following message

installation of 'python=3.7.1' into environment 'r-sjsdm' failed [error code 1]

There is a huge amount of output in the R Studio console - do you need me to post it ? Additionally - Could I email you directly with another general query about the package...its also probably easier to send you the console output from above in an email rather than here as well?

MaximilianPi commented 1 year ago

Yes, sure (maximilian.pichler@ur.de), but please run the code above without running the 'sjSDM::install_sjSDM()' function (the code above is the manual install, sry I didn't mention this).

MaximilianPi commented 1 year ago

Okay, so it seems that the problems were caused by an old existing conda installation. It works now.