pytorch / functorch

functorch is JAX-like composable function transforms for PyTorch.
https://pytorch.org/functorch/
BSD 3-Clause "New" or "Revised" License
1.38k stars 102 forks source link

Module not found after installation of nightly build #1032

Open zonexo opened 1 year ago

zonexo commented 1 year ago

Hi,

I am using a Nvidia machine learning code called Modulus.

It requires the use of pytorch and functorch.

I'm using a docker container from Nvidia (https://catalog.ngc.nvidia.com/orgs/nvidia/containers/pytorch) The pytorch version I have is 1.13.0a0+d321be6. I tried to install functorch nightly build and it was reported successful:

root@d337c6ba15b3:/examples_2209/helmholtz# pip install "git+https://github.com/pytorch/functorch.git" Looking in indexes: https://pypi.org/simple, https://pypi.ngc.nvidia.com Collecting git+https://github.com/pytorch/functorch.git Cloning https://github.com/pytorch/functorch.git to /tmp/pip-req-build-ihp2j8vw Running command git clone -q https://github.com/pytorch/functorch.git /tmp/pip-req-build-ihp2j8vw Resolved https://github.com/pytorch/functorch.git to commit 05284750f38d2a6ad8defe441d89562e7edf407b Requirement already satisfied: torch>=1.13.0.dev in /opt/conda/lib/python3.8/site-packages (from functorch==0.3.0a0+528475) (1.13.0a0+d321be6) Requirement already satisfied: typing_extensions in /opt/conda/lib/python3.8/site-packages (from torch>=1.13.0.dev->functorch==0.3.0a0+528475) (4.3.0) Building wheels for collected packages: functorch Building wheel for functorch (setup.py) ... done Created wheel for functorch: filename=functorch-0.3.0a0+528475-py2.py3-none-any.whl size=2240 sha256=cbaf2e64fa5fb47e196d9fd9676b7312cb65936caf988654523ad6d8efd681e4 Stored in directory: /tmp/pip-ephem-wheel-cache-obicds30/wheels/db/17/5b/938d2ee4d87a3156364c903c014c1e381a130429636147919b Successfully built functorch Installing collected packages: functorch Successfully installed functorch-0.3.0a0+528475

However, when I tried to run my code it reported functorch not found:

`root@d337c6ba15b3:/examples_2209/helmholtz# python Python 3.8.13 | packaged by conda-forge | (default, Mar 25 2022, 06:04:10) [GCC 10.3.0] on linux Type "help", "copyright", "credits" or "license" for more information.

import torch from functorch import vmap Traceback (most recent call last): File "", line 1, in ModuleNotFoundError: No module named 'functorch' exit() `

May I know why? Can you help?

Thanks!

zou3519 commented 1 year ago

@zonexo Installing functorch from source assumes you are using a recent PyTorch nightly. In general you must install the functorch that is closest to your pytorch commit hash.

There are two options:

  1. Is it possible to upgrade your pytorch installation to the latest pytorch nightly?
  2. Your pytorch version appears to be from 7/8/2022. Could you try to install the following functorch from 7/6?

    pip install "git+https://github.com/pytorch/functorch.git@590e8618"

zonexo commented 1 year ago

Hi Richard,

I tried to run:

pip install --pre torch -f https://download.pytorch.org/whl/nightly/cu113/torch_nightly.html --upgrade

but it told me I have the latest ver.

Anyway, I tried the second option and it worked! Now I know how to download a particular ver of a software.