dfalbel / torch

torch from R!
http://dfalbel.github.io/torch
Other
50 stars 5 forks source link

Could not install torch #6

Closed turgut090 closed 5 years ago

turgut090 commented 5 years ago

Hi, I installed libtorch, but get following from R:

devtools::install_github("dfalbel/torch")
Downloading GitHub repo dfalbel/torch@master
✔  checking for file ‘/private/var/folders/mc/8mc1v5ps3_gghm3j0n398y240000gn/T/RtmpgWC1W4/remotesb934cb95a3f/dfalbel-torch-df6b190/DESCRIPTION’ ...
─  preparing ‘torch’:
✔  checking DESCRIPTION meta-information ...
─  cleaning src
─  running ‘cleanup’
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
─  building ‘torch_0.0.1.9000.tar.gz’

* installing *source* package ‘torch’ ...
---------MacOS detected----------------
Using PKG_LIBS=-L/usr/local/lib/libtorch/lib -Wl,-rpath,/usr/local/lib/libtorch/lib -ltorch /usr/local/lib/libtorch/lib/libtorch.dylib /usr/local/lib/libtorch/lib/libcaffe2.dylib /usr/local/lib/libtorch/lib/libc10.dylib
Using PKG_CFLAGS=-I/usr/local/lib/libtorch/include -I/usr/local/lib/libtorch/include/torch/csrc/api/include
** libs
clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/lib/libtorch/include -I/usr/local/lib/libtorch/include/torch/csrc/api/include -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include" -I/usr/local/include   -fPIC  -Wall -g -O2 -c RcppExports.cpp -o RcppExports.o
clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/lib/libtorch/include -I/usr/local/lib/libtorch/include/torch/csrc/api/include -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include" -I/usr/local/include   -fPIC  -Wall -g -O2 -c tensor.cpp -o tensor.o
clang++ -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o torch.so RcppExports.o tensor.o -L/usr/local/lib/libtorch/lib -Wl,-rpath,/usr/local/lib/libtorch/lib -ltorch /usr/local/lib/libtorch/lib/libtorch.dylib /usr/local/lib/libtorch/lib/libcaffe2.dylib /usr/local/lib/libtorch/lib/libc10.dylib -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation.tbd and library file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation are out of sync. Falling back to library file for linking.
installing to /Library/Frameworks/R.framework/Versions/3.5/Resources/library/torch/libs
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
Error: package or namespace load failed for ‘torch’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/Library/Frameworks/R.framework/Versions/3.5/Resources/library/torch/libs/torch.so':
  dlopen(/Library/Frameworks/R.framework/Versions/3.5/Resources/library/torch/libs/torch.so, 6): Library not loaded: @rpath/libmklml.dylib
  Referenced from: /usr/local/lib/libtorch/lib/libcaffe2.dylib
  Reason: image not found
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/torch’
Error in i.p(...) : 
  (converted from warning) installation of package ‘/var/folders/mc/8mc1v5ps3_gghm3j0n398y240000gn/T//RtmpgWC1W4/fileb937e5f449e/torch_0.0.1.9000.tar.gz’ had non-zero exit status
dfalbel commented 5 years ago

Can you try installing libtorch from this address: https://github.com/dfalbel/torch/releases/download/v0.0.1.9000-alpha/libtorch.zip

Something changed with the most recent version from pytorch website and I still didn't figure out why this doesn't work.

Also, please note that this is a very early work in progress project and most torch functionality is not implemented.

turgut090 commented 5 years ago

Thank you, the link helped so much :-)

** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (torch)
tomasbarcellos commented 5 years ago

I get the same problem. I tried downloading It manually, but it haven't solved the issue.

Sys.setenv(TORCH_HOME="/libtorch")
devtools::install_github("dfalbel/torch")
#> Downloading GitHub repo dfalbel/torch@master
#> from URL https://api.github.com/repos/dfalbel/torch/zipball/master
#> Installing torch
#> '/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file  \
#>   --no-environ --no-save --no-restore --quiet CMD INSTALL  \
#>   '/private/var/folders/9z/k3cb3n413gldbcw9bp6tw5t00000gn/T/RtmpznAmoH/devtoolsd45ed497a5d/dfalbel-torch-3f2f260'  \
#>   --library='/Users/tomas/Library/R/3.5/library' --install-tests
#> 
#> Installation failed: Command failed (1)

Created on 2019-03-11 by the reprex package (v0.2.1)

The interactive session is more verbose:

devtools::install_github("dfalbel/torch")
Downloading GitHub repo dfalbel/torch@master
from URL https://api.github.com/repos/dfalbel/torch/zipball/master
Installing torch
'/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file  \
  --no-environ --no-save --no-restore --quiet CMD INSTALL  \
  '/private/var/folders/9z/k3cb3n413gldbcw9bp6tw5t00000gn/T/RtmpbOmi5U/devtoolsd3087d22f9f3/dfalbel-torch-3f2f260'  \
  --library='/Users/tomas/Library/R/3.5/library' --install-tests 

* installing *source* package ‘torch’ ...
----------------------------------------------------------------
TORCH_HOME env var is set - using it: /libtorch
TORCH_HOME directory exists - assuming library already installed
TORCH_BACKEND!='CUDA' - using 'CPU' backend
----------------------------------------------------------------
Using PKG_LIBS=-L/libtorch/lib -Wl,-rpath,/libtorch/lib -ltorch
Using PKG_CFLAGS=-I/libtorch/include -I/libtorch/include/torch/csrc/api/include
----------------------------------------------------------------
** libs
clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/libtorch/include -I/libtorch/include/torch/csrc/api/include -D_GLIBCXX_USE_CXX11_ABI=0 -I"/Users/tomas/Library/R/3.5/library/Rcpp/include" -I/usr/local/include   -fPIC  -Wall -g -O2 -c RcppExports.cpp -o RcppExports.o
clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/libtorch/include -I/libtorch/include/torch/csrc/api/include -D_GLIBCXX_USE_CXX11_ABI=0 -I"/Users/tomas/Library/R/3.5/library/Rcpp/include" -I/usr/local/include   -fPIC  -Wall -g -O2 -c cuda.cpp -o cuda.o
clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/libtorch/include -I/libtorch/include/torch/csrc/api/include -D_GLIBCXX_USE_CXX11_ABI=0 -I"/Users/tomas/Library/R/3.5/library/Rcpp/include" -I/usr/local/include   -fPIC  -Wall -g -O2 -c grad_mode.cpp -o grad_mode.o
clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/libtorch/include -I/libtorch/include/torch/csrc/api/include -D_GLIBCXX_USE_CXX11_ABI=0 -I"/Users/tomas/Library/R/3.5/library/Rcpp/include" -I/usr/local/include   -fPIC  -Wall -g -O2 -c tensor.cpp -o tensor.o
tensor.cpp:115:19: error: no matching member function for call to 'to'
  tensor = tensor.to(options);
           ~~~~~~~^~
/libtorch/include/ATen/core/TensorMethods.h:1208:23: note: candidate function not viable: no known conversion from 'torch::TensorOptions' to 'at::ScalarType' for 1st argument
inline Tensor Tensor::to(ScalarType dtype, bool non_blocking) const {
                      ^
/libtorch/include/ATen/core/TensorMethods.h:1211:23: note: candidate function not viable: no known conversion from 'torch::TensorOptions' to 'at::Device' for 1st argument
inline Tensor Tensor::to(Device device, bool non_blocking) const {
                      ^
/libtorch/include/ATen/core/TensorMethods.h:1214:23: note: candidate function not viable: no known conversion from 'torch::TensorOptions' to 'const at::Tensor' for 1st argument
inline Tensor Tensor::to(const Tensor & other, bool non_blocking) const {
                      ^
/libtorch/include/ATen/core/TensorMethods.h:1205:23: note: candidate function not viable: requires at least 2 arguments, but 1 was provided
inline Tensor Tensor::to(Device device, ScalarType dtype, bool non_blocking) const {
                      ^
tensor.cpp:127:19: error: no matching member function for call to 'to'
  tensor = tensor.to(tensor_options_(dtype, R_NilValue, device, R_NilValue));
           ~~~~~~~^~
/libtorch/include/ATen/core/TensorMethods.h:1208:23: note: candidate function not viable: no known conversion from 'torch::TensorOptions' to 'at::ScalarType' for 1st argument
inline Tensor Tensor::to(ScalarType dtype, bool non_blocking) const {
                      ^
/libtorch/include/ATen/core/TensorMethods.h:1211:23: note: candidate function not viable: no known conversion from 'torch::TensorOptions' to 'at::Device' for 1st argument
inline Tensor Tensor::to(Device device, bool non_blocking) const {
                      ^
/libtorch/include/ATen/core/TensorMethods.h:1214:23: note: candidate function not viable: no known conversion from 'torch::TensorOptions' to 'const at::Tensor' for 1st argument
inline Tensor Tensor::to(const Tensor & other, bool non_blocking) const {
                      ^
/libtorch/include/ATen/core/TensorMethods.h:1205:23: note: candidate function not viable: requires at least 2 arguments, but 1 was provided
inline Tensor Tensor::to(Device device, ScalarType dtype, bool non_blocking) const {
                      ^
tensor.cpp:686:29: error: no member named 'cholesky' in 'at::Tensor'
  return make_tensor_ptr(x->cholesky(upper));
                         ~  ^
tensor.cpp:849:29: error: no member named 'diag_embed' in 'at::Tensor'
  return make_tensor_ptr(x->diag_embed(offset, dim1, dim2));
                         ~  ^
tensor.cpp:925:10: error: no matching function for call to 'caffe_type_to_string'
  return caffe_type_to_string(x->dtype());
         ^~~~~~~~~~~~~~~~~~~~
./scalar.hpp:53:13: note: candidate function not viable: no known conversion from 'at::ScalarType' to 'caffe2::TypeMeta' for 1st argument
std::string caffe_type_to_string (caffe2::TypeMeta type) {
            ^
tensor.cpp:937:20: error: member reference base type 'at::ScalarType' is not a structure or union
  return x->dtype().itemsize();
         ~~~~~~~~~~^~~~~~~~~
tensor.cpp:1266:29: error: too many arguments to function call, expected 2, have 3; did you mean 'at::index_put_'?
  return make_tensor_ptr(x->index_put_(tensor_list_from_r_(indices), *values, accumulate));
                            ^~~~~~~~~~
                            at::index_put_
/libtorch/include/ATen/Functions.h:3700:24: note: 'at::index_put_' declared here
static inline Tensor & index_put_(Tensor & self, TensorList indices, const Tensor & values) {
                       ^
tensor.cpp:1342:31: error: no matching member function for call to 'mean'
    return make_tensor_ptr(x->mean(Rcpp::as<std::vector<std::int64_t>>(dim), keepdim));
                           ~~~^~~~
/libtorch/include/ATen/core/TensorMethods.h:863:23: note: candidate function not viable: no known conversion from 'std::__1::vector<long long, std::__1::allocator<long long> >' to 'int64_t' (aka 'long long') for 1st argument
inline Tensor Tensor::mean(int64_t dim, bool keepdim) const {
                      ^
/libtorch/include/ATen/core/TensorMethods.h:866:23: note: candidate function not viable: no known conversion from 'std::__1::vector<long long, std::__1::allocator<long long> >' to 'int64_t' (aka 'long long') for 1st argument
inline Tensor Tensor::mean(int64_t dim, ScalarType dtype) const {
                      ^
/libtorch/include/ATen/core/TensorMethods.h:854:23: note: candidate function not viable: requires single argument 'dtype', but 2 arguments were provided
inline Tensor Tensor::mean(ScalarType dtype) const {
                      ^
/libtorch/include/ATen/core/TensorMethods.h:860:23: note: candidate function not viable: requires 3 arguments, but 2 were provided
inline Tensor Tensor::mean(int64_t dim, bool keepdim, ScalarType dtype) const {
                      ^
/libtorch/include/ATen/core/TensorMethods.h:857:23: note: candidate function not viable: requires 0 arguments, but 2 were provided
inline Tensor Tensor::mean() const {
                      ^
8 errors generated.
make: *** [tensor.o] Error 1
ERROR: compilation failed for package ‘torch’
* removing ‘/Users/tomas/Library/R/3.5/library/torch’
Installation failed: Command failed (1)

Here is my session info:

devtools::session_info()
Session info --------------------------------------------------------------
 setting  value                       
 version  R version 3.5.0 (2018-04-23)
 system   x86_64, darwin15.6.0        
 ui       RStudio (1.1.453)           
 language (EN)                        
 collate  pt_BR.UTF-8                 
 tz       America/Sao_Paulo           
 date     2019-03-11                  

Packages ------------------------------------------------------------------
 package   * version date       source        
 backports   1.1.3   2018-12-14 cran (@1.1.3) 
 base      * 3.5.0   2018-04-24 local         
 callr       3.1.1   2018-12-21 cran (@3.1.1) 
 clipr       0.4.1   2018-06-23 CRAN (R 3.5.0)
 compiler    3.5.0   2018-04-24 local         
 curl        3.2     2018-03-28 CRAN (R 3.5.0)
 datasets  * 3.5.0   2018-04-24 local         
 devtools    1.13.5  2018-02-18 CRAN (R 3.5.0)
 digest      0.6.18  2018-10-10 cran (@0.6.18)
 evaluate    0.10.1  2017-06-24 CRAN (R 3.5.0)
 fs          1.2.6   2018-08-23 CRAN (R 3.5.0)
 git2r       0.23.0  2018-07-17 CRAN (R 3.5.0)
 graphics  * 3.5.0   2018-04-24 local         
 grDevices * 3.5.0   2018-04-24 local         
 htmltools   0.3.6   2017-04-28 CRAN (R 3.5.0)
 httr        1.3.1   2017-08-20 CRAN (R 3.5.0)
 knitr       1.20    2018-02-20 CRAN (R 3.5.0)
 magrittr    1.5     2014-11-22 CRAN (R 3.5.0)
 memoise     1.1.0   2017-04-21 CRAN (R 3.5.0)
 methods   * 3.5.0   2018-04-24 local         
 processx    3.3.0   2019-03-10 cran (@3.3.0) 
 ps          1.3.0   2018-12-21 cran (@1.3.0) 
 R6          2.4.0   2019-02-14 cran (@2.4.0) 
 Rcpp        1.0.0   2018-11-07 cran (@1.0.0) 
 reprex      0.2.1   2018-09-16 CRAN (R 3.5.0)
 rlang       0.3.1   2019-01-08 cran (@0.3.1) 
 rmarkdown   1.9     2018-03-01 CRAN (R 3.5.0)
 rprojroot   1.3-2   2018-01-03 CRAN (R 3.5.0)
 stats     * 3.5.0   2018-04-24 local         
 stringi     1.3.1   2019-02-13 cran (@1.3.1) 
 stringr     1.4.0   2019-02-10 CRAN (R 3.5.2)
 tools       3.5.0   2018-04-24 local         
 utils     * 3.5.0   2018-04-24 local         
 whisker     0.3-2   2013-04-28 CRAN (R 3.5.0)
 withr       2.1.2   2018-03-15 CRAN (R 3.5.0)
 yaml        2.2.0   2018-07-25 cran (@2.2.0) 
dfalbel commented 5 years ago

Can you tell me your clang --version and ls /libtorch? I think this can be related to compiler version or libtorch not being correctly linked.

tomasbarcellos commented 5 years ago

The clang info:

clang --version

Apple LLVM version 10.0.0 (clang-1000.10.44.4)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

And libtorch info:

ls /libtorch
bin     build-version   include     lib     share