Cannot import modules form torchrl

I am not able to import any torchrl module even if I have successfully installed it. I am using Google Collaboratory.
After a web search I have correctly working tensordict, that is indicated as an error source.
I have discovered that is specifically associated with the Multiagent Reinforcement Learning Tutorial.

https://pytorch.org/rl/tutorials/multiagent_ppo.html

It works correctly in other tutorials. Misteriously for me.
Thank for any comment to fix this problem

Thanks for reporting this! Do you mind giving the error message that you’re getting?

Thank you for your rapid answer.


  ImportError                               Traceback (most recent call last)
   <ipython-input-2-eaa873b138d0> in <cell line: 20>()
   18 
   19 # Multi-agent network
--->   20 from torchrl.modules import MultiAgentMLP, ProbabilisticActor, TanhNormal
       21 
       22 # Loss

ImportError: cannot import name 'MultiAgentMLP' from 'torchrl.modules' 
(/usr/local/lib/python3.10/dist-packages/torchrl/modules/__init__.py)

MARL pytorch tutorial

Thank in advance for help for fixing that issue

The tutorial is written with the nightlies. It will work seamlessly with the new release later this week!

Hi, I am running into the same import issue on the same tutorial. I have already installed the nightly build of torchRL with pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu118. Is there anything else I can do?

Specific error:

❯ python3 tutorial.py

Traceback (most recent call last):
  File "tutorial.py", line 20, in <module>
    from torchrl.modules import MultiAgentMLP, ProbabilisticActor, TanhNormal
ImportError: cannot import name 'MultiAgentMLP' from 'torchrl.modules' (/home/kfu38/.local/lib/python3.8/site-packages/torchrl/modules/__init__.py)

Never mind, the latest version of torchRL (v0.2.0) fixed my issues, thank you!

1 Like