Skip to content
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

Error: PyTorch not installed #79

Closed
lucaz88 opened this issue Oct 14, 2021 · 2 comments
Closed

Error: PyTorch not installed #79

lucaz88 opened this issue Oct 14, 2021 · 2 comments
Labels
question Further information is requested

Comments

@lucaz88
Copy link

lucaz88 commented Oct 14, 2021

Hi,
I am trying to install sjSDM on my laptop (Ubuntu 20.04 LTS, R 4.1.1) and I get the following error:

> library(sjSDM)
── Attaching sjSDM ──────────────────────────────────────────────────────────────────────────────────────── 0.1.8 ──
x torch 
x torch_optimizer 
x pyro 
x madgrad 

Torch or other dependencies not found:
	1. Use install_sjSDM() to install Pytorch and conda automatically 
	2. Installation trouble shooting guide: ?installation_help 
	3. If 1) and 2) did not help, please create an issue on <https://github.com/TheoreticalEcology/s-jSDM/issues> (see ?install_diagnostic) 

so then I run install_sjSDM() which seems to find all the required dependencies:

Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done

# All requested packages already installed.

Requirement already satisfied: pyro-ppl in /media/lucaz/DATA/miniconda3/envs/r-reticulate/lib/python3.9/site-packages (1.7.0)
Requirement already satisfied: torch_optimizer in /media/lucaz/DATA/miniconda3/envs/r-reticulate/lib/python3.9/site-packages (0.1.0)
Requirement already satisfied: madgrad in /media/lucaz/DATA/miniconda3/envs/r-reticulate/lib/python3.9/site-packages (1.1)
Requirement already satisfied: torch>=1.9.0 in /media/lucaz/DATA/miniconda3/envs/r-reticulate/lib/python3.9/site-packages (from pyro-ppl) (1.9.1)
Requirement already satisfied: tqdm>=4.36 in /media/lucaz/DATA/miniconda3/envs/r-reticulate/lib/python3.9/site-packages (from pyro-ppl) (4.62.0)
Requirement already satisfied: numpy>=1.7 in /media/lucaz/DATA/miniconda3/envs/r-reticulate/lib/python3.9/site-packages (from pyro-ppl) (1.21.2)
Requirement already satisfied: opt-einsum>=2.3.2 in /media/lucaz/DATA/miniconda3/envs/r-reticulate/lib/python3.9/site-packages (from pyro-ppl) (3.3.0)
Requirement already satisfied: pyro-api>=0.1.1 in /media/lucaz/DATA/miniconda3/envs/r-reticulate/lib/python3.9/site-packages (from pyro-ppl) (0.1.2)
Requirement already satisfied: pytorch-ranger>=0.1.1 in /media/lucaz/DATA/miniconda3/envs/r-reticulate/lib/python3.9/site-packages (from torch_optimizer) (0.1.1)
Requirement already satisfied: typing_extensions in /media/lucaz/DATA/miniconda3/envs/r-reticulate/lib/python3.9/site-packages (from torch>=1.9.0->pyro-ppl) (3.10.0.2)
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done

# All requested packages already installed.

Requirement already satisfied: pyro-ppl in /media/lucaz/DATA/miniconda3/envs/r-reticulate/lib/python3.9/site-packages (1.7.0)
Requirement already satisfied: torch_optimizer in /media/lucaz/DATA/miniconda3/envs/r-reticulate/lib/python3.9/site-packages (0.1.0)
Requirement already satisfied: opt-einsum>=2.3.2 in /media/lucaz/DATA/miniconda3/envs/r-reticulate/lib/python3.9/site-packages (from pyro-ppl) (3.3.0)
Requirement already satisfied: torch>=1.9.0 in /media/lucaz/DATA/miniconda3/envs/r-reticulate/lib/python3.9/site-packages (from pyro-ppl) (1.9.1)
Requirement already satisfied: tqdm>=4.36 in /media/lucaz/DATA/miniconda3/envs/r-reticulate/lib/python3.9/site-packages (from pyro-ppl) (4.62.0)
Requirement already satisfied: pyro-api>=0.1.1 in /media/lucaz/DATA/miniconda3/envs/r-reticulate/lib/python3.9/site-packages (from pyro-ppl) (0.1.2)
Requirement already satisfied: numpy>=1.7 in /media/lucaz/DATA/miniconda3/envs/r-reticulate/lib/python3.9/site-packages (from pyro-ppl) (1.21.2)
Requirement already satisfied: pytorch-ranger>=0.1.1 in /media/lucaz/DATA/miniconda3/envs/r-reticulate/lib/python3.9/site-packages (from torch_optimizer) (0.1.1)
Requirement already satisfied: typing_extensions in /media/lucaz/DATA/miniconda3/envs/r-reticulate/lib/python3.9/site-packages (from torch>=1.9.0->pyro-ppl) (3.10.0.2)

Installation complete.



Restarting R session...

but the test run still rise the same error:

> library(sjSDM)
> 
> set.seed(42)
> community <- simulate_SDM(sites = 100, species = 10, env = 3, se = TRUE)
> Env <- community$env_weights
> Occ <- community$response
> SP <- matrix(rnorm(200, 0, 0.3), 100, 2) # spatial coordinates (no effect on species occurences)
> 
> model <- sjSDM(Y = Occ, env = linear(data = Env, formula = ~X1+X2+X3), spatial = linear(data = SP, formula = ~0+X1:X2), se = TRUE, family=binomial("probit"), sampling = 100L)
── Attaching sjSDM ──────────────────────────────────────────────────────────────────────────────────────── 0.1.8 ──
x torch 
x torch_optimizer 
x pyro 
x madgrad 

Torch or other dependencies not found:
	1. Use install_sjSDM() to install Pytorch and conda automatically 
	2. Installation trouble shooting guide: ?installation_help 
	3. If 1) and 2) did not help, please create an issue on <https://github.com/TheoreticalEcology/s-jSDM/issues> (see ?install_diagnostic) 
Error: PyTorch not installed

Any idea about what might be the problem? I already have miniconda installed on my laptop, maybe is conflicting with the installation workflow?

Thanks for your help,
Luca

@MaximilianPi
Copy link
Member

Hi Luca,

yes, I agree with your suspicion that your other miniconda might be the problem:

Run in a fresh R-session:

  1. reticulate::conda_list() should list the available conda environments, copy the r-reticulate python path
  2. reticulate::use_condaenv("r-reticulate") and reticulate::use_python("")
  3. load library(sjSDM)
  4. If it didn't work, run step 2+3 again and refresh your r-session before loading sjSDM

If the above mentioned steps didn't help you should delete one of your miniconda installation, I assume that you favour your own miniconda installation:

  1. Delete r-miniconda the folder (you can get the path of r-miniconda via reticulate::conda_list() )
  2. use your miniconda to setup a new env for sjSDM:
  • $conda create -n r-reticulate python=3.8
  • $conda activate r-reticulate
  • see https://pytorch.org/get-started/locally/ for the correct conda install command
  • $python -m pip install pyro-ppl madgrad torch-optimizer
  1. in R: reticulate::use_condaenv("r-reticulate")

@lucaz88
Copy link
Author

lucaz88 commented Oct 20, 2021

Hi Maximillian,

thanks for your help! The first solution actually worked for me and now I can successfully load the library by preselecting the conda env at each initialization of R:

reticulate::use_python("/media/.../miniconda3/envs/r-reticulate/bin/python")
library(sjSDM)

Cheers
Luca

@MaximilianPi MaximilianPi added the question Further information is requested label Dec 21, 2021
MaximilianPi added a commit that referenced this issue Dec 23, 2021
MaximilianPi added a commit that referenced this issue Jan 5, 2022
# V1.0.0

## Major changes

* revised anova: `sjSDM::anova(...)` corresponds now to a type I anova (removed CV) #76
* `sjSDM::Rsquared()` uses now Nagelkerke or McFadden R-squared (which is also used in the anova) #76
* deprecated `sjSDM::sLVM` because of instability issues and other reasons
* revised `sjSDM::install_sjSDM()`, it works now for all x64 systems/versions #81 #79 #71

## Minor changes

* removed several unnecessary dependencies (e.g. dplyr)
* improved documentation of all functions, e.g. see `?sjSDM`
* new `sjSDM::update.sjSDM` method to re-fit model with different formula(s)
* new `sjSDM::sjSDM.tune` method to fit quickly a model with optimized regularization parameters (from `sjSDM::sjSDM_cv`)

## Bug fixes

* revised memory problem in `sjSDM::sjSDM_cv()` #84
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants