Closed ManuelSpinola closed 5 months ago
Hi @ManuelSpinola,
try the following commands (in a new session):
reticulate::conda_remove("r-sjSDM")
reticulate::conda_create(envname = "r-sjsdm", python_version = "3.10")
reticulate::conda_install(envname = "r-sjsdm",
packages =c("pytorch::pytorch", "torchvision", "torchaudio", "-c", "pytorch"))
reticulate::conda_install(envname = "r-sjsdm",
packages = c("pyro-ppl", "torch_optimizer", "madgrad", "tqdm"), pip = TRUE)
Thank you. I got the following error when I tried the package example:
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)
Iter: 0/100 0%| | [00:00, ?it/s]
Error in py_call_impl(callable, call_args$unnamed, call_args$named) :
ModuleNotFoundError: No module named 'torch.backends.opt_einsum'
Run reticulate::py_last_error()
for details.
Timing stopped at: 0.021 0.001 0.022
reticulate::py_last_error()
── Python Exception Message ──────────────────────────────────────────────────── Traceback (most recent call last): File "/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/sjSDM/python/sjSDM_py/model_sjSDM.py", line 453, in fit loss = self._loss_function(mu, y, self.sigma, batch_size, sampling, df, alpha, device, self.dtype) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/sjSDM/python/sjSDM_py/model_sjSDM.py", line 848, in tmp E = torch.sigmoid( torch.einsum("ijk, lk -> ijl", [noise, sigma]).add(mu).mul(alpha) ).mul(0.999999).add(0.0000005) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/manuelspinola/miniconda3/envs/r-sjsdm/lib/python3.11/site-packages/torch/functional.py", line 336, in einsum File "/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/reticulate/python/rpytools/loader.py", line 122, in _find_and_load_hook return _run_hook(name, _hook) ^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/reticulate/python/rpytools/loader.py", line 96, in _run_hook module = hook() ^^^^^^ File "/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/reticulate/python/rpytools/loader.py", line 120, in _hook return _find_andload(name, import) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ModuleNotFoundError: No module named 'torch.backends.opt_einsum'
── R Traceback ───────────────────────────────────────────────────────────────── ▆
reticulate::py_last_error()$r_trace$full_call
for more details.Can you please install the development sjSDM version? (you do not have to re-install the python setup):
devtools::install_github("https://github.com/TheoreticalEcology/s-jSDM", subdir = "sjSDM", ref = "master")
If it still does not work, please post again the output of sjSDM::install_diagnostic()
It works! Thank you very much.
great!
Hi, I have problem installing sjSDM.
install_diagnostic()
EnvironmentLocationNotFound: Not a conda environment: /Users/manuelspinola/miniconda3/envs/anaconda3
EnvironmentLocationNotFound: Not a conda environment: /Users/manuelspinola/miniconda3/envs/anaconda3
1 base /Users/manuelspinola/miniconda3/bin/python 2 anaconda3 /opt/anaconda3/bin/python
ENV: base
torch:
packages in environment at /Users/manuelspinola/miniconda3:
#
Name Version Build Channel
pytorch-ranger 0.1.1 pypi_0 pypi torch 2.3.0 pypi_0 pypi torch-optimizer 0.3.0 pypi_0 pypi torchaudio 2.3.0 pypi_0 pypi torchvision 0.18.0 pypi_0 pypi
numpy:
packages in environment at /Users/manuelspinola/miniconda3:
#
Name Version Build Channel
numpy 1.26.4 pypi_0 pypi
ENV: anaconda3
torch:
numpy:
python: /usr/local/bin/python3.11 libpython: /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/config-3.11-darwin/libpython3.11.dylib pythonhome: /Library/Frameworks/Python.framework/Versions/3.11:/Library/Frameworks/Python.framework/Versions/3.11 version: 3.11.3 (v3.11.3:f3909b8bc8, Apr 4 2023, 20:12:10) [Clang 13.0.0 (clang-1300.0.29.30)] numpy: [NOT FOUND] torch: [NOT FOUND]
NOTE: Python version was forced by use_python() function
populated config files : /Users/manuelspinola/.condarc conda version : 24.5.0 conda-build version : not installed python version : 3.11.4.final.0 solver : libmamba (default) virtual packages : archspec=1=m1 conda=24.5.0=0 osx=14.5=0 unix=0=0 base environment : /Users/manuelspinola/miniconda3 (writable) conda av data dir : /Users/manuelspinola/miniconda3/etc/conda conda av metadata url : None channel URLs : https://repo.anaconda.com/pkgs/main/osx-arm64 https://repo.anaconda.com/pkgs/main/noarch https://repo.anaconda.com/pkgs/r/osx-arm64 https://repo.anaconda.com/pkgs/r/noarch package cache : /Users/manuelspinola/miniconda3/pkgs /Users/manuelspinola/.conda/pkgs envs directories : /Users/manuelspinola/miniconda3/envs /Users/manuelspinola/.conda/envs platform : osx-arm64 user-agent : conda/24.5.0 requests/2.29.0 CPython/3.11.4 Darwin/23.5.0 OSX/14.5 solver/libmamba conda-libmamba-solver/24.1.0 libmambapy/1.5.8 UID:GID : 501:20 netrc file : None offline mode : False