diff --git a/.circleci/config.yml b/.circleci/config.yml index 8aa7dc9855b..a804188cbb5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -315,20 +315,22 @@ jobs: paths: - conda - env - - run: - # Here we create an envlist file that contains some env variables that we want the docker container to be aware of. - # Normally, the CIRCLECI variable is set and available on all CI workflows: https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables. - # They're available in all the other workflows (OSX and Windows). - # But here, we're running the unittest_linux_gpu workflows in a docker container, where those variables aren't accessible. - # So instead we dump the variables we need in env.list and we pass that file when invoking "docker run". - name: export CIRCLECI env var - command: echo "CIRCLECI=true" >> ./env.list +# - run: +# # Here we create an envlist file that contains some env variables that we want the docker container to be aware of. +# # Normally, the CIRCLECI variable is set and available on all CI workflows: https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables. +# # They're available in all the other workflows (OSX and Windows). +# # But here, we're running the unittest_linux_gpu workflows in a docker container, where those variables aren't accessible. +# # So instead we dump the variables we need in env.list and we pass that file when invoking "docker run". +# name: export CIRCLECI env var +# command: echo "CIRCLECI=true" >> ./env.list - run: name: Install torchrl +# command: bash .circleci/unittest/linux/scripts/install.sh command: docker run -t --gpus all -v $PWD:$PWD -w $PWD -e UPLOAD_CHANNEL -e CU_VERSION "${image_name}" .circleci/unittest/linux/scripts/install.sh - run: name: Run tests - command: docker run --env-file ./env.list -t --gpus all -v $PWD:$PWD -w $PWD "${image_name}" .circleci/unittest/linux/scripts/run_test.sh + command: bash .circleci/unittest/linux/scripts/run_test.sh +# command: docker run --env-file ./env.list -t --gpus all -v $PWD:$PWD -w $PWD "${image_name}" .circleci/unittest/linux/scripts/run_test.sh - run: name: Post Process command: docker run -t --gpus all -v $PWD:$PWD -w $PWD "${image_name}" .circleci/unittest/linux/scripts/post_process.sh @@ -368,20 +370,22 @@ jobs: paths: - conda - env - - run: - # Here we create an envlist file that contains some env variables that we want the docker container to be aware of. - # Normally, the CIRCLECI variable is set and available on all CI workflows: https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables. - # They're available in all the other workflows (OSX and Windows). - # But here, we're running the unittest_linux_gpu workflows in a docker container, where those variables aren't accessible. - # So instead we dump the variables we need in env.list and we pass that file when invoking "docker run". - name: export CIRCLECI env var - command: echo "CIRCLECI=true" >> ./env.list +# - run: +# # Here we create an envlist file that contains some env variables that we want the docker container to be aware of. +# # Normally, the CIRCLECI variable is set and available on all CI workflows: https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables. +# # They're available in all the other workflows (OSX and Windows). +# # But here, we're running the unittest_linux_gpu workflows in a docker container, where those variables aren't accessible. +# # So instead we dump the variables we need in env.list and we pass that file when invoking "docker run". +# name: export CIRCLECI env var +# command: echo "CIRCLECI=true" >> ./env.list - run: name: Install torchrl - command: docker run -t --gpus all -v $PWD:$PWD -w $PWD -e UPLOAD_CHANNEL -e CU_VERSION "${image_name}" .circleci/unittest/linux_optdeps/scripts/install.sh +# command: bash .circleci/unittest/linux_optdeps/scripts/install.sh + command: docker run -t --gpus all -v $PWD:$PWD -w $PWD -e UPLOAD_CHANNEL -e CU_VERSION "${image_name}" .circleci/unittest/linux/scripts/install.sh - run: name: Run tests - command: docker run --env-file ./env.list -t --gpus all -v $PWD:$PWD -w $PWD "${image_name}" .circleci/unittest/linux_optdeps/scripts/run_test.sh + command: bash .circleci/unittest/linux_optdeps/scripts/run_test.sh +# command: docker run --env-file ./env.list -t --gpus all -v $PWD:$PWD -w $PWD "${image_name}" .circleci/unittest/linux/scripts/run_test.sh - run: name: Post Process command: docker run -t --gpus all -v $PWD:$PWD -w $PWD "${image_name}" .circleci/unittest/linux_optdeps/scripts/post_process.sh @@ -468,20 +472,22 @@ jobs: paths: - conda - env - - run: - # Here we create an envlist file that contains some env variables that we want the docker container to be aware of. - # Normally, the CIRCLECI variable is set and available on all CI workflows: https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables. - # They're availble in all the other workflows (OSX and Windows). - # But here, we're running the unittest_linux_gpu workflows in a docker container, where those variables aren't accessible. - # So instead we dump the variables we need in env.list and we pass that file when invoking "docker run". - name: export CIRCLECI env var - command: echo "CIRCLECI=true" >> ./env.list +# - run: +# # Here we create an envlist file that contains some env variables that we want the docker container to be aware of. +# # Normally, the CIRCLECI variable is set and available on all CI workflows: https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables. +# # They're available in all the other workflows (OSX and Windows). +# # But here, we're running the unittest_linux_gpu workflows in a docker container, where those variables aren't accessible. +# # So instead we dump the variables we need in env.list and we pass that file when invoking "docker run". +# name: export CIRCLECI env var +# command: echo "CIRCLECI=true" >> ./env.list - run: name: Install torchrl - command: docker run -t --gpus all -v $PWD:$PWD -w $PWD -e UPLOAD_CHANNEL -e CU_VERSION "${image_name}" .circleci/unittest/linux_stable/scripts/install.sh +# command: bash .circleci/unittest/linux_stable/scripts/install.sh + command: docker run -t --gpus all -v $PWD:$PWD -w $PWD -e UPLOAD_CHANNEL -e CU_VERSION "${image_name}" .circleci/unittest/linux/scripts/install.sh - run: name: Run tests - command: docker run --env-file ./env.list -t --gpus all -v $PWD:$PWD -w $PWD "${image_name}" .circleci/unittest/linux_stable/scripts/run_test.sh + command: bash .circleci/unittest/linux_stable/scripts/run_test.sh +# command: docker run --env-file ./env.list -t --gpus all -v $PWD:$PWD -w $PWD "${image_name}" .circleci/unittest/linux/scripts/run_test.sh - run: name: Post Process command: docker run -t --gpus all -v $PWD:$PWD -w $PWD "${image_name}" .circleci/unittest/linux_stable/scripts/post_process.sh diff --git a/.circleci/unittest/linux/scripts/setup_env.sh b/.circleci/unittest/linux/scripts/setup_env.sh index b0cf2b465b1..d4ab971c35d 100755 --- a/.circleci/unittest/linux/scripts/setup_env.sh +++ b/.circleci/unittest/linux/scripts/setup_env.sh @@ -53,12 +53,13 @@ printf "* Installing dependencies (except PyTorch)\n" echo " - python=${PYTHON_VERSION}" >> "${this_dir}/environment.yml" cat "${this_dir}/environment.yml" + if [[ $OSTYPE == 'darwin'* ]]; then PRIVATE_MUJOCO_GL=glfw -else - conda install -y -c conda-forge mesa - conda install -y -c conda-forge mesalib +elif [ "${CU_VERSION:-}" == cpu ]; then PRIVATE_MUJOCO_GL=osmesa +else + PRIVATE_MUJOCO_GL=egl fi export MUJOCO_GL=$PRIVATE_MUJOCO_GL @@ -67,6 +68,18 @@ conda env config vars set MUJOCO_PY_MUJOCO_PATH=$root_dir/.mujoco/mujoco210 \ MJLIB_PATH=$root_dir/.mujoco/mujoco-2.1.1/lib/libmujoco.so.2.1.1 \ LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$root_dir/.mujoco/mujoco210/bin \ SDL_VIDEODRIVER=dummy \ - MUJOCO_GL=$PRIVATE_MUJOCO_GL + MUJOCO_GL=$PRIVATE_MUJOCO_GL \ + PYOPENGL_PLATFORM=$PRIVATE_MUJOCO_GL + +# Software rendering requires GLX and OSMesa. +if [ $PRIVATE_MUJOCO_GL == 'egl' ] || [ $PRIVATE_MUJOCO_GL == 'osmesa' ] ; then + yum makecache + yum install -y glfw + yum install -y glew + yum install -y mesa-libGL + yum install -y mesa-libOSMesa-devel + yum -y install egl-utils + yum -y install freeglut +fi conda env update --file "${this_dir}/environment.yml" --prune diff --git a/.circleci/unittest/linux_stable/scripts/setup_env.sh b/.circleci/unittest/linux_stable/scripts/setup_env.sh index c9c6e45acc2..d4ab971c35d 100755 --- a/.circleci/unittest/linux_stable/scripts/setup_env.sh +++ b/.circleci/unittest/linux_stable/scripts/setup_env.sh @@ -40,7 +40,7 @@ conda activate "${env_dir}" # 3. Install mujoco printf "* Installing mujoco and related\n" -mkdir $root_dir/.mujoco +mkdir -p $root_dir/.mujoco cd $root_dir/.mujoco/ wget https://github.com/deepmind/mujoco/releases/download/2.1.1/mujoco-2.1.1-linux-x86_64.tar.gz tar -xf mujoco-2.1.1-linux-x86_64.tar.gz @@ -56,10 +56,10 @@ cat "${this_dir}/environment.yml" if [[ $OSTYPE == 'darwin'* ]]; then PRIVATE_MUJOCO_GL=glfw -else - conda install -y -c conda-forge mesa - conda install -y -c conda-forge mesalib +elif [ "${CU_VERSION:-}" == cpu ]; then PRIVATE_MUJOCO_GL=osmesa +else + PRIVATE_MUJOCO_GL=egl fi export MUJOCO_GL=$PRIVATE_MUJOCO_GL @@ -68,6 +68,18 @@ conda env config vars set MUJOCO_PY_MUJOCO_PATH=$root_dir/.mujoco/mujoco210 \ MJLIB_PATH=$root_dir/.mujoco/mujoco-2.1.1/lib/libmujoco.so.2.1.1 \ LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$root_dir/.mujoco/mujoco210/bin \ SDL_VIDEODRIVER=dummy \ - MUJOCO_GL=$PRIVATE_MUJOCO_GL + MUJOCO_GL=$PRIVATE_MUJOCO_GL \ + PYOPENGL_PLATFORM=$PRIVATE_MUJOCO_GL + +# Software rendering requires GLX and OSMesa. +if [ $PRIVATE_MUJOCO_GL == 'egl' ] || [ $PRIVATE_MUJOCO_GL == 'osmesa' ] ; then + yum makecache + yum install -y glfw + yum install -y glew + yum install -y mesa-libGL + yum install -y mesa-libOSMesa-devel + yum -y install egl-utils + yum -y install freeglut +fi conda env update --file "${this_dir}/environment.yml" --prune diff --git a/test/test_libs.py b/test/test_libs.py index 1c9da094699..8499a35a419 100644 --- a/test/test_libs.py +++ b/test/test_libs.py @@ -105,7 +105,7 @@ def test_gym(env_name, frame_skip, from_pixels, pixels_only): @pytest.mark.skipif(not _has_dmc, reason="no dm_control library found") -@pytest.mark.parametrize("env_name,task", [["cheetah", "run"], ["humanoid", "walk"]]) +@pytest.mark.parametrize("env_name,task", [["cheetah", "run"]]) @pytest.mark.parametrize("frame_skip", [1, 3]) @pytest.mark.parametrize( "from_pixels,pixels_only", @@ -118,35 +118,32 @@ def test_gym(env_name, frame_skip, from_pixels, pixels_only): def test_dmcontrol(env_name, task, frame_skip, from_pixels, pixels_only): if from_pixels and (not torch.has_cuda or not torch.cuda.device_count()): raise pytest.skip("no cuda device") - env0 = DMControlEnv( - env_name, - task, - frame_skip=frame_skip, - from_pixels=from_pixels, - pixels_only=pixels_only, - ) - torch.manual_seed(0) - np.random.seed(0) - final_seed0 = env0.set_seed(0) - tdreset0 = env0.reset() - rollout0 = env0.rollout(max_steps=50) - env0.close() - del env0 - env1 = DMControlEnv( - env_name, - task, - frame_skip=frame_skip, - from_pixels=from_pixels, - pixels_only=pixels_only, - ) - torch.manual_seed(0) - np.random.seed(0) - final_seed1 = env1.set_seed(0) - tdreset1 = env1.reset() - rollout1 = env1.rollout(max_steps=50) - env1.close() - del env1 + tds = [] + tds_reset = [] + final_seed = [] + for i in range(2): + env0 = DMControlEnv( + env_name, + task, + frame_skip=frame_skip, + from_pixels=from_pixels, + pixels_only=pixels_only, + ) + torch.manual_seed(0) + np.random.seed(0) + final_seed0 = env0.set_seed(0) + tdreset0 = env0.reset() + rollout0 = env0.rollout(max_steps=50) + env0.close() + del env0 + tds_reset.append(tdreset0) + tds.append(rollout0) + final_seed.append(final_seed0) + + tdreset1, tdreset0 = tds_reset + rollout0, rollout1 = tds + final_seed0, final_seed1 = final_seed assert_allclose_td(tdreset1, tdreset0) assert final_seed0 == final_seed1