rstudio / reticulate

R Interface to Python
https://rstudio.github.io/reticulate
Apache License 2.0
1.65k stars 325 forks source link

ModuleNotFoundError: No module named 'mxnet-cu100' #957

Closed vidarsumo closed 3 years ago

vidarsumo commented 3 years ago

Hi,

I'm trying to use GPU with the GluonTS library but getting ModuleNotFoundError.

This is my code:

reticulate::py_install(
  envname  = "gpu-gluonts",
  python_version = "3.6",
  packages = c(
    "mxnet-cu100",
    "gluonts",
    "pandas",
    "numpy",
    "pathlib"
  ),
  method = "conda",
  pip = TRUE
)

library(dplyr)
my_gluonts_env_python_path <- reticulate::conda_list() %>%
  filter(name == "gpu-gluonts") %>%
  pull(python)

Sys.setenv(GLUONTS_PYTHON = my_gluonts_env_python_path)

library(modeltime.gluonts)

mxnet <- reticulate::import("mxnet-cu100")

and the import results in

Error in py_module_import(module, convert = convert) : ModuleNotFoundError: No module named 'mxnet-cu100'

I checked if I was connected to the environment, which I am.

reticulate::py_discover_config()
python:         C:/Miniconda/envs/gpu-gluonts/python.exe
libpython:      C:/Miniconda/envs/gpu-gluonts/python36.dll
pythonhome:     C:/Miniconda/envs/gpu-gluonts
version:        3.6.12 |Anaconda, Inc.| (default, Sep  9 2020, 00:29:25) [MSC v.1916 64 bit (AMD64)]
Architecture:   64bit
numpy:          C:/Miniconda/envs/gpu-gluonts/Lib/site-packages/numpy
numpy_version:  1.16.6

NOTE: Python version was forced by RETICULATE_PYTHON

The package seems to be installed

# packages in environment at c:\Miniconda\envs\gpu-gluonts:
#
# Name                    Version                   Build  Channel
certifi                   2020.12.5        py36haa95532_0
chardet                   3.0.4                    pypi_0    pypi
convertdate               2.3.0                    pypi_0    pypi
cycler                    0.10.0                   pypi_0    pypi
dataclasses               0.8                      pypi_0    pypi
gluonts                   0.6.6                    pypi_0    pypi
hijri-converter           2.1.1                    pypi_0    pypi
holidays                  0.10.5.2                 pypi_0    pypi
idna                      2.6                      pypi_0    pypi
kiwisolver                1.3.1                    pypi_0    pypi
korean-lunar-calendar     0.2.1                    pypi_0    pypi
matplotlib                3.3.4                    pypi_0    pypi
mxnet-cu100               1.5.0                    pypi_0    pypi
numpy                     1.16.6                   pypi_0    pypi
pandas                    1.1.5                    pypi_0    pypi
pathlib                   1.0.1                    pypi_0    pypi
pillow                    8.1.0                    pypi_0    pypi
pip                       21.0.1             pyhd8ed1ab_0    conda-forge
pydantic                  1.6.1                    pypi_0    pypi
pymeeus                   0.3.7                    pypi_0    pypi
pyparsing                 2.4.7                    pypi_0    pypi
python                    3.6.12               h5500b2f_2
python-dateutil           2.8.1                    pypi_0    pypi
python-graphviz           0.8.4                    pypi_0    pypi
python_abi                3.6                     1_cp36m    conda-forge
pytz                      2021.1                   pypi_0    pypi
requests                  2.18.4                   pypi_0    pypi
setuptools                49.6.0           py36ha15d459_3    conda-forge
six                       1.15.0                   pypi_0    pypi
sqlite                    3.33.0               h2a8f88b_0
toolz                     0.11.1                   pypi_0    pypi
tqdm                      4.56.2                   pypi_0    pypi
ujson                     1.35                     pypi_0    pypi
urllib3                   1.22                     pypi_0    pypi
vc                        14.2                 hb210afc_3    conda-forge
vs2015_runtime            14.28.29325          h5e1d092_3    conda-forge
wheel                     0.36.2             pyhd3deb0d_0    conda-forge
wincertstore              0.2             py36ha15d459_1006    conda-forge
zlib                      1.2.11               h62dcd97_4

Any idea why this is happening?

Session info:

R version 4.0.3 (2020-10-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows Server x64 (build 17763)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] forcats_0.5.1           stringr_1.4.0           purrr_0.3.4             readr_1.4.0             tidyr_1.1.2            
 [6] tibble_3.0.6            ggplot2_3.3.3           tidyverse_1.3.0         modeltime.gluonts_0.2.0 modeltime_0.4.1        
[11] dplyr_1.0.4            

loaded via a namespace (and not attached):
 [1] reticulate_1.18-9007 tinytex_0.28         tidyselect_1.1.0     xfun_0.20            haven_2.3.1          lattice_0.20-41     
 [7] parsnip_0.1.5        colorspace_2.0-0     vctrs_0.3.6          generics_0.1.0       rlang_0.4.10         pillar_1.4.7        
[13] withr_2.4.1          glue_1.4.2           DBI_1.1.0            rappdirs_0.3.3       dbplyr_2.0.0         modelr_0.1.8        
[19] readxl_1.3.1         lifecycle_1.0.0      plyr_1.8.6           munsell_0.5.0        gtable_0.3.0         cellranger_1.1.0    
[25] rvest_0.3.6          broom_0.7.3          Rcpp_1.0.6           scales_1.1.1         backports_1.2.1      RcppParallel_5.0.2  
[31] StanHeaders_2.21.0-7 jsonlite_1.7.2       fs_1.5.0             hms_1.0.0            stringi_1.5.3        grid_4.0.3          
[37] cli_2.3.0            tools_4.0.3          magrittr_2.0.1       crayon_1.4.1         pkgconfig_2.0.3      ellipsis_0.3.1      
[43] Matrix_1.2-18        xml2_1.3.2           pROC_1.17.0.1        reprex_1.0.0         lubridate_1.7.9.2    rstudioapi_0.13     
[49] assertthat_0.2.1     yardstick_0.0.7      httr_1.4.2           R6_2.5.0             compiler_4.0.3      
kevinushey commented 3 years ago

My suspicion is that even though the package on pip is called mxnet-cu100 the module you'd import and use in Python is just called mxnet. Does a plain reticulate::import("mxnet") work for you?

vidarsumo commented 3 years ago

This worked! Thank you so much.