@@ -826,85 +826,52 @@ If you're using TorchRL, please refer to this BibTeX entry to cite this work:
826
826
827
827
## Installation
828
828
829
- Create a conda environment where the packages will be installed.
829
+ ### Create a new virtual environment:
830
+ ``` bash
831
+ python -m venv torchrl
832
+ source torchrl/bin/activate # On Windows use: venv\Scripts\activate
833
+ ```
834
+
835
+ Or create a conda environment where the packages will be installed.
830
836
831
837
```
832
- conda create --name torch_rl python=3.9
833
- conda activate torch_rl
838
+ conda create --name torchrl python=3.9
839
+ conda activate torchrl
834
840
```
835
841
836
- ** PyTorch **
842
+ ### Install dependencies:
837
843
838
- Depending on the use of functorch that you want to make, you may want to
844
+ #### PyTorch
845
+
846
+ Depending on the use of torchrl that you want to make, you may want to
839
847
install the latest (nightly) PyTorch release or the latest stable version of PyTorch.
840
848
See [ here] ( https://pytorch.org/get-started/locally/ ) for a detailed list of commands,
841
849
including ` pip3 ` or other special installation instructions.
842
850
843
- ** Torchrl**
851
+ TorchRL offers a few pre-defined dependencies such as ` "torchrl[tests]" ` , ` "torchrl[atari]" ` etc.
852
+
853
+ #### Torchrl
844
854
845
855
You can install the ** latest stable release** by using
846
856
``` bash
847
857
pip3 install torchrl
848
858
```
849
- This should work on linux, Windows 10 and OsX (Intel or Silicon chips).
850
- On certain Windows machines (Windows 11), one should install the library locally (see below).
851
-
852
- For AArch64 machines, the binaries are not yet stored on PyPI so you will need to download them directly from
853
- the [ release page] ( https://github.com/pytorch/rl/releases/ ) or install the library via
854
- ```
855
- pip3 install git+https://github.com/pytorch/rl@v0.8.0
856
- ```
859
+ This should work on linux (including AArch64 machines), Windows 10 and OsX (Metal chips only).
860
+ On certain Windows machines (Windows 11), one should build the library locally.
861
+ This can be done in two ways:
857
862
858
- The ** nightly build** can be installed via
859
- ``` bash
860
- pip3 install tensordict-nightly torchrl-nightly
861
- ```
862
- which we currently only ship for Linux machines.
863
- Importantly, the nightly builds require the nightly builds of PyTorch too.
864
-
865
- To install extra dependencies, call
866
- ``` bash
867
- pip3 install " torchrl[atari,dm_control,gym_continuous,rendering,tests,utils,marl,open_spiel,checkpointing]"
868
- ```
869
- or a subset of these.
870
-
871
- To install torchrl with the latest pytorch, use
872
- ``` bash
873
- pip3 install " torchrl[replay_buffer]"
874
- ```
875
- since some features in the replay buffer require PyTorch 2.7.0 or above.
876
-
877
- One may also desire to install the library locally. Three main reasons can motivate this:
878
- - the nightly/stable release isn't available for one's platform (eg, Windows 11, nightlies for Apple Silicon etc.);
879
- - contributing to the code;
880
- - install torchrl with a previous version of PyTorch (any version >= 2.1) (note that this should also be doable via a regular install followed
881
- by a downgrade to a previous pytorch version -- but the C++ binaries will not be available so some feature will not work,
882
- such as prioritized replay buffers and the like.)
883
-
884
- ** Disclaimer** : As of today, TorchRL is roughly compatible with any pytorch version >= 2.1 and installing it will not
885
- directly require a newer version of pytorch to be installed. Indirectly though, tensordict still requires the latest
886
- PyTorch to be installed and we are working hard to loosen that requirement.
887
- The C++ binaries of TorchRL (mainly for prioritized replay buffers) will only work with PyTorch 2.7.0 and above.
888
- Some features (e.g., working with nested jagged tensors) may also
889
- be limited with older versions of pytorch. It is recommended to use the latest TorchRL with the latest PyTorch version
890
- unless there is a strong reason not to do so.
891
-
892
- To install the library locally, start by cloning the repo:
893
863
``` bash
864
+ # Install and build locally v0.8.1 of the library without cloning
865
+ pip3 install git+https://github.com/pytorch/rl@v0.8.1
866
+ # Clone the library and build it locally
867
+ git clone https://github.com/pytorch/tensordict
894
868
git clone https://github.com/pytorch/rl
895
- ```
896
- and don't forget to check out the branch or tag you want to use for the build:
897
- ``` bash
898
- git checkout v0.8.0
869
+ pip install -e tensordict
870
+ pip install -e rl
899
871
```
900
872
901
- Go to the directory where you have cloned the torchrl repo and install it (after
902
- installing ` ninja ` )
903
- ``` bash
904
- cd /path/to/torchrl/
905
- pip3 install ninja -U
906
- python setup.py develop
907
- ```
873
+ Note that tensordict local build requires ` cmake ` to be installed via [ homebrew] ( https://brew.sh/ ) (MacOS) or another package manager
874
+ such as ` apt ` , ` apt-get ` , ` conda ` or ` yum ` but NOT ` pip ` , as well as ` pip install "pybind11[global]" ` .
908
875
909
876
One can also build the wheels to distribute to co-workers using
910
877
``` bash
@@ -915,22 +882,22 @@ Your wheels will be stored there `./dist/torchrl<name>.whl` and installable via
915
882
pip install torchrl< name> .whl
916
883
```
917
884
918
- ** Warning** : Unfortunately, ` pip3 install -e . ` does not currently work. Contributions to help fix this are welcome!
919
-
920
- On M1 machines, this should work out-of-the-box with the nightly build of PyTorch.
921
- If the generation of this artifact in MacOs M1 doesn't work correctly or in the execution the message
922
- ` (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')) ` appears, then try
923
-
924
- ```
925
- ARCHFLAGS="-arch arm64" python setup.py develop
885
+ The ** nightly build** can be installed via
886
+ ``` bash
887
+ pip3 install tensordict-nightly torchrl-nightly
926
888
```
889
+ which we currently only ship for Linux machines.
890
+ Importantly, the nightly builds require the nightly builds of PyTorch too.
891
+ Also, a local build of torchrl with the nightly build of tensordict may fail - install both nightlies or both local builds but do not mix them.
927
892
928
- To run a quick sanity check, leave that directory (e.g. by executing ` cd ~/ ` )
929
- and try to import the library.
930
- ```
931
- python -c "import torchrl"
932
- ```
933
- This should not return any warning or error.
893
+
894
+ ** Disclaimer** : As of today, TorchRL is roughly compatible with any pytorch version >= 2.1 and installing it will not
895
+ directly require a newer version of pytorch to be installed. Indirectly though, tensordict still requires the latest
896
+ PyTorch to be installed and we are working hard to loosen that requirement.
897
+ The C++ binaries of TorchRL (mainly for prioritized replay buffers) will only work with PyTorch 2.7.0 and above.
898
+ Some features (e.g., working with nested jagged tensors) may also
899
+ be limited with older versions of pytorch. It is recommended to use the latest TorchRL with the latest PyTorch version
900
+ unless there is a strong reason not to do so.
934
901
935
902
** Optional dependencies**
936
903
@@ -959,43 +926,6 @@ pip3 install tensorboard
959
926
pip3 install wandb
960
927
```
961
928
962
- ** Troubleshooting**
963
-
964
- If a ` ModuleNotFoundError: No module named ‘torchrl._torchrl ` errors occurs (or
965
- a warning indicating that the C++ binaries could not be loaded),
966
- it means that the C++ extensions were not installed or not found.
967
-
968
- - One common reason might be that you are trying to import torchrl from within the
969
- git repo location. The following code snippet should return an error if
970
- torchrl has not been installed in ` develop ` mode:
971
- ```
972
- cd ~/path/to/rl/repo
973
- python -c 'from torchrl.envs.libs.gym import GymEnv'
974
- ```
975
- If this is the case, consider executing torchrl from another location.
976
- - If you're not importing torchrl from within its repo location, it could be
977
- caused by a problem during the local installation. Check the log after the
978
- ` python setup.py develop ` . One common cause is a g++/C++ version discrepancy
979
- and/or a problem with the ` ninja ` library.
980
- - If the problem persists, feel free to open an issue on the topic in the repo,
981
- we'll make our best to help!
982
- - On ** MacOs** , we recommend installing XCode first.
983
- With Apple Silicon M1 chips, make sure you are using the arm64-built python
984
- (e.g. [ here] ( https://betterprogramming.pub/how-to-install-pytorch-on-apple-m1-series-512b3ad9bc6 ) ).
985
- Running the following lines of code
986
- ```
987
- wget https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py
988
- python collect_env.py
989
- ```
990
- should display
991
- ```
992
- OS: macOS *** (arm64)
993
- ```
994
- and not
995
- ```
996
- OS: macOS **** (x86_64)
997
- ```
998
-
999
929
Versioning issues can cause error message of the type ``` undefined symbol ```
1000
930
and such. For these, refer to the [ versioning issues document] ( https://github.com/pytorch/rl/blob/main/knowledge_base/VERSIONING_ISSUES.md )
1001
931
for a complete explanation and proposed workarounds.
0 commit comments