From fb9cc2c7b88882ac2f82b5f43031ec459fb9f6b7 Mon Sep 17 00:00:00 2001 From: Vincent Moens Date: Tue, 10 Sep 2024 16:19:10 +0100 Subject: [PATCH] [CI] Fix broken workflows (#2428) --- .github/unittest/linux_libs/scripts_gym/batch_scripts.sh | 1 + .github/unittest/linux_libs/scripts_gym/environment.yml | 1 - .github/unittest/linux_libs/scripts_gym/install.sh | 3 ++- .github/unittest/linux_libs/scripts_habitat/setup_env.sh | 7 ++++--- .github/unittest/linux_olddeps/scripts_gym_0_13/install.sh | 2 +- torchrl/collectors/collectors.py | 7 ++++--- 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.github/unittest/linux_libs/scripts_gym/batch_scripts.sh b/.github/unittest/linux_libs/scripts_gym/batch_scripts.sh index 11921b44821..9622984a421 100755 --- a/.github/unittest/linux_libs/scripts_gym/batch_scripts.sh +++ b/.github/unittest/linux_libs/scripts_gym/batch_scripts.sh @@ -6,6 +6,7 @@ DIR="$(cd "$(dirname "$0")" && pwd)" set -e +set -v eval "$(./conda/bin/conda shell.bash hook)" conda activate ./env diff --git a/.github/unittest/linux_libs/scripts_gym/environment.yml b/.github/unittest/linux_libs/scripts_gym/environment.yml index 4c0c9269479..d30aa6d0f91 100644 --- a/.github/unittest/linux_libs/scripts_gym/environment.yml +++ b/.github/unittest/linux_libs/scripts_gym/environment.yml @@ -7,7 +7,6 @@ dependencies: - pip: # Initial version is required to install Atari ROMS in setup_env.sh - gym[atari]==0.13 - - minigrid - hypothesis - future - cloudpickle diff --git a/.github/unittest/linux_libs/scripts_gym/install.sh b/.github/unittest/linux_libs/scripts_gym/install.sh index d3eac779861..a66fe5fddd1 100755 --- a/.github/unittest/linux_libs/scripts_gym/install.sh +++ b/.github/unittest/linux_libs/scripts_gym/install.sh @@ -7,6 +7,7 @@ unset PYTORCH_VERSION apt-get update && apt-get install -y git wget gcc g++ set -e +set -v eval "$(./conda/bin/conda shell.bash hook)" conda activate ./env @@ -39,7 +40,7 @@ printf "Installing PyTorch with %s\n" "${CU_VERSION}" if [ "${CU_VERSION:-}" == cpu ] ; then conda install pytorch==2.0 torchvision==0.15 cpuonly -c pytorch -y else - conda install pytorch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 pytorch-cuda=11.8 -c pytorch -c nvidia -y + conda install pytorch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 pytorch-cuda=11.8 numpy==1.26 numpy-base==1.26 -c pytorch -c nvidia -y fi # Solving circular import: https://stackoverflow.com/questions/75501048/how-to-fix-attributeerror-partially-initialized-module-charset-normalizer-has diff --git a/.github/unittest/linux_libs/scripts_habitat/setup_env.sh b/.github/unittest/linux_libs/scripts_habitat/setup_env.sh index fc182a669ea..6ad970c3f47 100755 --- a/.github/unittest/linux_libs/scripts_habitat/setup_env.sh +++ b/.github/unittest/linux_libs/scripts_habitat/setup_env.sh @@ -67,8 +67,9 @@ pip install pip --upgrade conda env update --file "${this_dir}/environment.yml" --prune -#conda install habitat-sim withbullet headless -c conda-forge -c aihabitat -y conda install habitat-sim withbullet headless -c conda-forge -c aihabitat -y -conda run python -m pip install git+https://github.com/facebookresearch/habitat-lab.git@stable#subdirectory=habitat-lab -#conda run python -m pip install git+https://github.com/facebookresearch/habitat-lab.git#subdirectory=habitat-baselines +git clone https://github.com/facebookresearch/habitat-lab.git +cd habitat-lab +pip3 install -e habitat-lab +pip3 install -e habitat-baselines # install habitat_baselines conda run python -m pip install "gym[atari,accept-rom-license]" pygame diff --git a/.github/unittest/linux_olddeps/scripts_gym_0_13/install.sh b/.github/unittest/linux_olddeps/scripts_gym_0_13/install.sh index 58a33cd43f4..7b7c857c37a 100755 --- a/.github/unittest/linux_olddeps/scripts_gym_0_13/install.sh +++ b/.github/unittest/linux_olddeps/scripts_gym_0_13/install.sh @@ -39,7 +39,7 @@ printf "Installing PyTorch with %s\n" "${CU_VERSION}" if [ "${CU_VERSION:-}" == cpu ] ; then conda install pytorch==2.0 torchvision==0.15 cpuonly -c pytorch -y else - conda install pytorch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 pytorch-cuda=11.8 -c pytorch -c nvidia -y + conda install pytorch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 pytorch-cuda=11.8 numpy==1.26 numpy-base==1.26 -c pytorch -c nvidia -y fi # Solving circular import: https://stackoverflow.com/questions/75501048/how-to-fix-attributeerror-partially-initialized-module-charset-normalizer-has diff --git a/torchrl/collectors/collectors.py b/torchrl/collectors/collectors.py index 4a10f4304f2..80fb1c1f768 100644 --- a/torchrl/collectors/collectors.py +++ b/torchrl/collectors/collectors.py @@ -507,7 +507,8 @@ def __init__( # Cuda handles sync if torch.cuda.is_available(): self._sync_storage = torch.cuda.synchronize - elif torch.backends.mps.is_available(): + elif torch.backends.mps.is_available() and hasattr(torch, "mps"): + # Will break for older PT versions which don't have torch.mps self._sync_storage = torch.mps.synchronize elif self.storing_device.type == "cpu": self._sync_storage = _do_nothing @@ -521,7 +522,7 @@ def __init__( # Cuda handles sync if torch.cuda.is_available(): self._sync_env = torch.cuda.synchronize - elif torch.backends.mps.is_available(): + elif torch.backends.mps.is_available() and hasattr(torch, "mps"): self._sync_env = torch.mps.synchronize elif self.env_device.type == "cpu": self._sync_env = _do_nothing @@ -534,7 +535,7 @@ def __init__( # Cuda handles sync if torch.cuda.is_available(): self._sync_policy = torch.cuda.synchronize - elif torch.backends.mps.is_available(): + elif torch.backends.mps.is_available() and hasattr(torch, "mps"): self._sync_policy = torch.mps.synchronize elif self.policy_device.type == "cpu": self._sync_policy = _do_nothing