Open fengruan opened 4 years ago
From the package installation list I don’t see that PyTorch or Torchvision are being installed.
You may have several conda environments installed, and maybe one of them, has already PyTorch installed. From the text that you sent, it seems that you have PyTorch installed in the base
or root Anaconda installation, which is not recommended.
Try using this command:
conda create -n r-torch python=3.6.6 pytorch torchvision cpuonly matplotlib pandas --channel pytorch
This should create a new conda environment r-torch
. rTorch will recognize it. You can test it from the terminal first with
conda activate r-torch
Then, run Python. import torch and test some PyTorch code. If it works, you are ready to go.
Restart R or RStudio to allow them to sense the changes in conda.
Let me know how it goes.
Thanks for the feedback. However, it seems that it still does not work. Let me know if you have further suggestions. Thanks!
Here is what I did.
(1) Type the following command in the terminal
conda create -n r-torch python=3.6.6 pytorch torchvision cpuonly matplotlib pandas --channel pytorch
Everything seems working afterwards.
(2) Next I type the following command in the terminal, it seems working again.
conda activate r-torch
(r-torch) Feng-s-MacBook:~ fengruan$ python Python 3.6.6 |Anaconda, Inc.| (default, Jun 28 2018, 11:07:29) [GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin Type "help", "copyright", "credits" or "license" for more information.
import torch mnist_4d = torch.FloatTensor(60000, 3, 28, 28) mnist_4d[0,0] tensor([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
(3) However, when I restart R, there's still this error message:
library(rTorch) rTorch::torch_config() Warning message: In print.pytorch_config(x) : Installation of Torch not found.
Python environments searched for 'rTorch' package: /Users/fengruan/Library/r-miniconda/envs/r-reticulate/bin/python3.6
You can install PyTorch using the install_pytorch() function.
Hi Alfonso,
I tried the following code on my computer to install the r-torch. It runs into error.
What I did is the following:
(1) Open R and type the following command.
install.packages("rTorch")
Afterwards, I think I have successfully installed rTorch.
(2) Open terminal and type the following command as suggested:
conda install python=3.6.6 pytorch torchvision cpuonly matplotlib pandas --channel pytorch
I attached what I see here. It seems that everything is installed. Nothing is going wrong here.
Collecting package metadata (current_repodata.json): done Solving environment: done
Package Plan
environment location: /opt/anaconda3/envs/myenv
added / updated specs:
The following NEW packages will be INSTALLED:
ca-certificates pkgs/main/osx-64::ca-certificates-2020.6.24-0 certifi pkgs/main/osx-64::certifi-2020.6.20-py37_0 libcxx pkgs/main/osx-64::libcxx-10.0.0-1 libedit pkgs/main/osx-64::libedit-3.1.20191231-h1de35cc_1 libffi pkgs/main/osx-64::libffi-3.3-hb1e8313_2 ncurses pkgs/main/osx-64::ncurses-6.2-h0a44026_1 openssl pkgs/main/osx-64::openssl-1.1.1g-h1de35cc_0 pip pkgs/main/osx-64::pip-20.2.1-py37_0 python pkgs/main/osx-64::python-3.7.7-hf48f09d_4 readline pkgs/main/osx-64::readline-8.0-h1de35cc_0 setuptools pkgs/main/osx-64::setuptools-49.2.1-py37_0 sqlite pkgs/main/osx-64::sqlite-3.32.3-hffcf06c_0 tk pkgs/main/osx-64::tk-8.6.10-hb0a8c7a_0 wheel pkgs/main/osx-64::wheel-0.34.2-py37_0 xz pkgs/main/osx-64::xz-5.2.5-h1de35cc_0 zlib pkgs/main/osx-64::zlib-1.2.11-h1de35cc_3
Proceed ([y]/n)? y
Preparing transaction: done Verifying transaction: done Executing transaction: done
(3) Open R again. Type
library(rTorch) rTorch::torch_config()
I get the error message. It suggests that it can't find pytorch.
Warning message: In print.pytorch_config(x) : Installation of Torch not found.
Python environments searched for 'rTorch' package: /Users/fengruan/Library/r-miniconda/envs/r-reticulate/bin/python3.6
You can install PyTorch using the install_pytorch() function.
(4) Open Python in terminal and double check whether pytorch is installed
It seems that it is installed..at least on python 3.8.3? It seems to suggest that r-torch can't find the pytorch which is installed on my computer?
python
(base) Feng-s-MacBook:Dropbox fengruan$ python Python 3.8.3 (default, Jul 2 2020, 11:26:31) [Clang 10.0.0 ] :: Anaconda, Inc. on darwin Type "help", "copyright", "credits" or "license" for more information.