2024-06-05 15:53:02 +00:00
{
lib ,
buildPythonPackage ,
pythonOlder ,
fetchFromGitHub ,
2024-09-19 14:19:46 +00:00
# build-system
2024-06-05 15:53:02 +00:00
ninja ,
setuptools ,
which ,
2024-09-19 14:19:46 +00:00
# dependencies
2024-06-05 15:53:02 +00:00
cloudpickle ,
numpy ,
2024-09-19 14:19:46 +00:00
packaging ,
tensordict ,
2024-06-05 15:53:02 +00:00
torch ,
2024-09-19 14:19:46 +00:00
# optional-dependencies
2024-06-05 15:53:02 +00:00
ale-py ,
gym ,
pygame ,
torchsnapshot ,
gymnasium ,
mujoco ,
h5py ,
huggingface-hub ,
minari ,
pandas ,
pillow ,
requests ,
scikit-learn ,
torchvision ,
tqdm ,
moviepy ,
git ,
hydra-core ,
tensorboard ,
wandb ,
2024-09-19 14:19:46 +00:00
# checks
2024-06-05 15:53:02 +00:00
imageio ,
pytest-rerunfailures ,
pytestCheckHook ,
pyyaml ,
scipy ,
2024-09-19 14:19:46 +00:00
2024-06-05 15:53:02 +00:00
stdenv ,
2024-01-25 14:12:00 +00:00
} :
buildPythonPackage rec {
pname = " t o r c h r l " ;
2024-09-19 14:19:46 +00:00
version = " 0 . 5 . 0 " ;
2024-01-25 14:12:00 +00:00
pyproject = true ;
disabled = pythonOlder " 3 . 8 " ;
src = fetchFromGitHub {
owner = " p y t o r c h " ;
repo = " r l " ;
rev = " r e f s / t a g s / v ${ version } " ;
2024-09-19 14:19:46 +00:00
hash = " s h a 2 5 6 - u D p O d O u H T q K F K s p H O p l 8 4 k D 9 a d E K Z j v O 2 G n Y u L 2 7 H 5 c = " ;
2024-01-25 14:12:00 +00:00
} ;
2024-05-15 15:35:15 +00:00
build-system = [
2024-01-25 14:12:00 +00:00
ninja
setuptools
which
] ;
2024-05-15 15:35:15 +00:00
dependencies = [
2024-01-25 14:12:00 +00:00
cloudpickle
numpy
packaging
tensordict
torch
] ;
2024-09-19 14:19:46 +00:00
optional-dependencies = {
2024-01-25 14:12:00 +00:00
atari = [
ale-py
gym
pygame
] ;
2024-06-05 15:53:02 +00:00
checkpointing = [ torchsnapshot ] ;
2024-01-25 14:12:00 +00:00
gym-continuous = [
gymnasium
mujoco
] ;
2024-05-15 15:35:15 +00:00
offline-data = [
h5py
huggingface-hub
minari
pandas
pillow
requests
scikit-learn
torchvision
tqdm
] ;
2024-06-05 15:53:02 +00:00
rendering = [ moviepy ] ;
2024-01-25 14:12:00 +00:00
utils = [
git
hydra-core
tensorboard
tqdm
wandb
] ;
} ;
# torchrl needs to create a folder to store datasets
preBuild = ''
export D4RL_DATASET_DIR = $ ( mktemp - d )
'' ;
2024-06-05 15:53:02 +00:00
pythonImportsCheck = [ " t o r c h r l " ] ;
2024-01-25 14:12:00 +00:00
# We have to delete the source because otherwise it is used instead of the installed package.
preCheck = ''
rm - rf torchrl
export XDG_RUNTIME_DIR = $ ( mktemp - d )
'' ;
2024-06-05 15:53:02 +00:00
nativeCheckInputs =
[
2024-09-19 14:19:46 +00:00
h5py
2024-06-05 15:53:02 +00:00
gymnasium
imageio
pytest-rerunfailures
pytestCheckHook
pyyaml
scipy
torchvision
]
2024-09-19 14:19:46 +00:00
++ optional-dependencies . atari
++ optional-dependencies . gym-continuous
++ optional-dependencies . rendering ;
2024-01-25 14:12:00 +00:00
disabledTests = [
# mujoco.FatalError: an OpenGL platform library has not been loaded into this process, this most likely means that a valid OpenGL context has not been created before mjr_makeContext was called
" t e s t _ v e c e n v s _ e n v "
# ValueError: Can't write images with one color channel.
" t e s t _ l o g _ v i d e o "
# Those tests require the ALE environments (provided by unpackaged shimmy)
" t e s t _ c o l l e c t o r _ e n v _ r e s e t "
" t e s t _ g y m "
" t e s t _ g y m _ f a k e _ t d "
" t e s t _ r e c o r d e r "
" t e s t _ r e c o r d e r _ l o a d "
" t e s t _ r o l l o u t "
" t e s t _ p a r a l l e l _ t r a n s _ e n v _ c h e c k "
" t e s t _ s e r i a l _ t r a n s _ e n v _ c h e c k "
" t e s t _ s i n g l e _ t r a n s _ e n v _ c h e c k "
" t e s t _ t d _ c r e a t i o n _ f r o m _ s p e c "
" t e s t _ t r a n s _ p a r a l l e l _ e n v _ c h e c k "
" t e s t _ t r a n s _ s e r i a l _ e n v _ c h e c k "
" t e s t _ t r a n s f o r m _ e n v "
2024-06-20 14:57:18 +00:00
# undeterministic
" t e s t _ d i s t r i b u t e d _ c o l l e c t o r _ u p d a t e p o l i c y "
" t e s t _ t i m e i t "
2024-09-19 14:19:46 +00:00
# On a 24 threads system
# assert torch.get_num_threads() == max(1, init_threads - 3)
# AssertionError: assert 23 == 21
" t e s t _ a u t o _ n u m _ t h r e a d s "
2024-01-25 14:12:00 +00:00
] ;
2024-09-19 14:19:46 +00:00
meta = {
2024-06-20 14:57:18 +00:00
description = " M o d u l a r , p r i m i t i v e - f i r s t , p y t h o n - f i r s t P y T o r c h l i b r a r y f o r R e i n f o r c e m e n t L e a r n i n g " ;
2024-01-25 14:12:00 +00:00
homepage = " h t t p s : / / g i t h u b . c o m / p y t o r c h / r l " ;
2024-04-21 15:54:59 +00:00
changelog = " h t t p s : / / g i t h u b . c o m / p y t o r c h / r l / r e l e a s e s / t a g / v ${ version } " ;
2024-09-19 14:19:46 +00:00
license = lib . licenses . mit ;
maintainers = with lib . maintainers ; [ GaetanLepage ] ;
2024-05-15 15:35:15 +00:00
# ~3k tests fail with: RuntimeError: internal error
2024-01-25 14:12:00 +00:00
} ;
}