Skip to content

Commit 30ef218

Browse files
authored
[CircleCI] Fix dm_control rendering (#339)
1 parent 2f2105e commit 30ef218

File tree

4 files changed

+95
-67
lines changed

4 files changed

+95
-67
lines changed

.circleci/config.yml

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -315,20 +315,22 @@ jobs:
315315
paths:
316316
- conda
317317
- env
318-
- run:
319-
# Here we create an envlist file that contains some env variables that we want the docker container to be aware of.
320-
# Normally, the CIRCLECI variable is set and available on all CI workflows: https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables.
321-
# They're available in all the other workflows (OSX and Windows).
322-
# But here, we're running the unittest_linux_gpu workflows in a docker container, where those variables aren't accessible.
323-
# So instead we dump the variables we need in env.list and we pass that file when invoking "docker run".
324-
name: export CIRCLECI env var
325-
command: echo "CIRCLECI=true" >> ./env.list
318+
# - run:
319+
# # Here we create an envlist file that contains some env variables that we want the docker container to be aware of.
320+
# # Normally, the CIRCLECI variable is set and available on all CI workflows: https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables.
321+
# # They're available in all the other workflows (OSX and Windows).
322+
# # But here, we're running the unittest_linux_gpu workflows in a docker container, where those variables aren't accessible.
323+
# # So instead we dump the variables we need in env.list and we pass that file when invoking "docker run".
324+
# name: export CIRCLECI env var
325+
# command: echo "CIRCLECI=true" >> ./env.list
326326
- run:
327327
name: Install torchrl
328+
# command: bash .circleci/unittest/linux/scripts/install.sh
328329
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
329330
- run:
330331
name: Run tests
331-
command: docker run --env-file ./env.list -t --gpus all -v $PWD:$PWD -w $PWD "${image_name}" .circleci/unittest/linux/scripts/run_test.sh
332+
command: bash .circleci/unittest/linux/scripts/run_test.sh
333+
# command: docker run --env-file ./env.list -t --gpus all -v $PWD:$PWD -w $PWD "${image_name}" .circleci/unittest/linux/scripts/run_test.sh
332334
- run:
333335
name: Post Process
334336
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:
368370
paths:
369371
- conda
370372
- env
371-
- run:
372-
# Here we create an envlist file that contains some env variables that we want the docker container to be aware of.
373-
# Normally, the CIRCLECI variable is set and available on all CI workflows: https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables.
374-
# They're available in all the other workflows (OSX and Windows).
375-
# But here, we're running the unittest_linux_gpu workflows in a docker container, where those variables aren't accessible.
376-
# So instead we dump the variables we need in env.list and we pass that file when invoking "docker run".
377-
name: export CIRCLECI env var
378-
command: echo "CIRCLECI=true" >> ./env.list
373+
# - run:
374+
# # Here we create an envlist file that contains some env variables that we want the docker container to be aware of.
375+
# # Normally, the CIRCLECI variable is set and available on all CI workflows: https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables.
376+
# # They're available in all the other workflows (OSX and Windows).
377+
# # But here, we're running the unittest_linux_gpu workflows in a docker container, where those variables aren't accessible.
378+
# # So instead we dump the variables we need in env.list and we pass that file when invoking "docker run".
379+
# name: export CIRCLECI env var
380+
# command: echo "CIRCLECI=true" >> ./env.list
379381
- run:
380382
name: Install torchrl
381-
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
383+
# command: bash .circleci/unittest/linux_optdeps/scripts/install.sh
384+
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
382385
- run:
383386
name: Run tests
384-
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
387+
command: bash .circleci/unittest/linux_optdeps/scripts/run_test.sh
388+
# command: docker run --env-file ./env.list -t --gpus all -v $PWD:$PWD -w $PWD "${image_name}" .circleci/unittest/linux/scripts/run_test.sh
385389
- run:
386390
name: Post Process
387391
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:
468472
paths:
469473
- conda
470474
- env
471-
- run:
472-
# Here we create an envlist file that contains some env variables that we want the docker container to be aware of.
473-
# Normally, the CIRCLECI variable is set and available on all CI workflows: https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables.
474-
# They're availble in all the other workflows (OSX and Windows).
475-
# But here, we're running the unittest_linux_gpu workflows in a docker container, where those variables aren't accessible.
476-
# So instead we dump the variables we need in env.list and we pass that file when invoking "docker run".
477-
name: export CIRCLECI env var
478-
command: echo "CIRCLECI=true" >> ./env.list
475+
# - run:
476+
# # Here we create an envlist file that contains some env variables that we want the docker container to be aware of.
477+
# # Normally, the CIRCLECI variable is set and available on all CI workflows: https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables.
478+
# # They're available in all the other workflows (OSX and Windows).
479+
# # But here, we're running the unittest_linux_gpu workflows in a docker container, where those variables aren't accessible.
480+
# # So instead we dump the variables we need in env.list and we pass that file when invoking "docker run".
481+
# name: export CIRCLECI env var
482+
# command: echo "CIRCLECI=true" >> ./env.list
479483
- run:
480484
name: Install torchrl
481-
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
485+
# command: bash .circleci/unittest/linux_stable/scripts/install.sh
486+
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
482487
- run:
483488
name: Run tests
484-
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
489+
command: bash .circleci/unittest/linux_stable/scripts/run_test.sh
490+
# command: docker run --env-file ./env.list -t --gpus all -v $PWD:$PWD -w $PWD "${image_name}" .circleci/unittest/linux/scripts/run_test.sh
485491
- run:
486492
name: Post Process
487493
command: docker run -t --gpus all -v $PWD:$PWD -w $PWD "${image_name}" .circleci/unittest/linux_stable/scripts/post_process.sh

.circleci/unittest/linux/scripts/setup_env.sh

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,13 @@ printf "* Installing dependencies (except PyTorch)\n"
5353
echo " - python=${PYTHON_VERSION}" >> "${this_dir}/environment.yml"
5454
cat "${this_dir}/environment.yml"
5555

56+
5657
if [[ $OSTYPE == 'darwin'* ]]; then
5758
PRIVATE_MUJOCO_GL=glfw
58-
else
59-
conda install -y -c conda-forge mesa
60-
conda install -y -c conda-forge mesalib
59+
elif [ "${CU_VERSION:-}" == cpu ]; then
6160
PRIVATE_MUJOCO_GL=osmesa
61+
else
62+
PRIVATE_MUJOCO_GL=egl
6263
fi
6364

6465
export MUJOCO_GL=$PRIVATE_MUJOCO_GL
@@ -67,6 +68,18 @@ conda env config vars set MUJOCO_PY_MUJOCO_PATH=$root_dir/.mujoco/mujoco210 \
6768
MJLIB_PATH=$root_dir/.mujoco/mujoco-2.1.1/lib/libmujoco.so.2.1.1 \
6869
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$root_dir/.mujoco/mujoco210/bin \
6970
SDL_VIDEODRIVER=dummy \
70-
MUJOCO_GL=$PRIVATE_MUJOCO_GL
71+
MUJOCO_GL=$PRIVATE_MUJOCO_GL \
72+
PYOPENGL_PLATFORM=$PRIVATE_MUJOCO_GL
73+
74+
# Software rendering requires GLX and OSMesa.
75+
if [ $PRIVATE_MUJOCO_GL == 'egl' ] || [ $PRIVATE_MUJOCO_GL == 'osmesa' ] ; then
76+
yum makecache
77+
yum install -y glfw
78+
yum install -y glew
79+
yum install -y mesa-libGL
80+
yum install -y mesa-libOSMesa-devel
81+
yum -y install egl-utils
82+
yum -y install freeglut
83+
fi
7184

7285
conda env update --file "${this_dir}/environment.yml" --prune

.circleci/unittest/linux_stable/scripts/setup_env.sh

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ conda activate "${env_dir}"
4040

4141
# 3. Install mujoco
4242
printf "* Installing mujoco and related\n"
43-
mkdir $root_dir/.mujoco
43+
mkdir -p $root_dir/.mujoco
4444
cd $root_dir/.mujoco/
4545
wget https://github.com/deepmind/mujoco/releases/download/2.1.1/mujoco-2.1.1-linux-x86_64.tar.gz
4646
tar -xf mujoco-2.1.1-linux-x86_64.tar.gz
@@ -56,10 +56,10 @@ cat "${this_dir}/environment.yml"
5656

5757
if [[ $OSTYPE == 'darwin'* ]]; then
5858
PRIVATE_MUJOCO_GL=glfw
59-
else
60-
conda install -y -c conda-forge mesa
61-
conda install -y -c conda-forge mesalib
59+
elif [ "${CU_VERSION:-}" == cpu ]; then
6260
PRIVATE_MUJOCO_GL=osmesa
61+
else
62+
PRIVATE_MUJOCO_GL=egl
6363
fi
6464

6565
export MUJOCO_GL=$PRIVATE_MUJOCO_GL
@@ -68,6 +68,18 @@ conda env config vars set MUJOCO_PY_MUJOCO_PATH=$root_dir/.mujoco/mujoco210 \
6868
MJLIB_PATH=$root_dir/.mujoco/mujoco-2.1.1/lib/libmujoco.so.2.1.1 \
6969
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$root_dir/.mujoco/mujoco210/bin \
7070
SDL_VIDEODRIVER=dummy \
71-
MUJOCO_GL=$PRIVATE_MUJOCO_GL
71+
MUJOCO_GL=$PRIVATE_MUJOCO_GL \
72+
PYOPENGL_PLATFORM=$PRIVATE_MUJOCO_GL
73+
74+
# Software rendering requires GLX and OSMesa.
75+
if [ $PRIVATE_MUJOCO_GL == 'egl' ] || [ $PRIVATE_MUJOCO_GL == 'osmesa' ] ; then
76+
yum makecache
77+
yum install -y glfw
78+
yum install -y glew
79+
yum install -y mesa-libGL
80+
yum install -y mesa-libOSMesa-devel
81+
yum -y install egl-utils
82+
yum -y install freeglut
83+
fi
7284

7385
conda env update --file "${this_dir}/environment.yml" --prune

test/test_libs.py

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def test_gym(env_name, frame_skip, from_pixels, pixels_only):
105105

106106

107107
@pytest.mark.skipif(not _has_dmc, reason="no dm_control library found")
108-
@pytest.mark.parametrize("env_name,task", [["cheetah", "run"], ["humanoid", "walk"]])
108+
@pytest.mark.parametrize("env_name,task", [["cheetah", "run"]])
109109
@pytest.mark.parametrize("frame_skip", [1, 3])
110110
@pytest.mark.parametrize(
111111
"from_pixels,pixels_only",
@@ -118,35 +118,32 @@ def test_gym(env_name, frame_skip, from_pixels, pixels_only):
118118
def test_dmcontrol(env_name, task, frame_skip, from_pixels, pixels_only):
119119
if from_pixels and (not torch.has_cuda or not torch.cuda.device_count()):
120120
raise pytest.skip("no cuda device")
121-
env0 = DMControlEnv(
122-
env_name,
123-
task,
124-
frame_skip=frame_skip,
125-
from_pixels=from_pixels,
126-
pixels_only=pixels_only,
127-
)
128-
torch.manual_seed(0)
129-
np.random.seed(0)
130-
final_seed0 = env0.set_seed(0)
131-
tdreset0 = env0.reset()
132-
rollout0 = env0.rollout(max_steps=50)
133-
env0.close()
134-
del env0
135121

136-
env1 = DMControlEnv(
137-
env_name,
138-
task,
139-
frame_skip=frame_skip,
140-
from_pixels=from_pixels,
141-
pixels_only=pixels_only,
142-
)
143-
torch.manual_seed(0)
144-
np.random.seed(0)
145-
final_seed1 = env1.set_seed(0)
146-
tdreset1 = env1.reset()
147-
rollout1 = env1.rollout(max_steps=50)
148-
env1.close()
149-
del env1
122+
tds = []
123+
tds_reset = []
124+
final_seed = []
125+
for i in range(2):
126+
env0 = DMControlEnv(
127+
env_name,
128+
task,
129+
frame_skip=frame_skip,
130+
from_pixels=from_pixels,
131+
pixels_only=pixels_only,
132+
)
133+
torch.manual_seed(0)
134+
np.random.seed(0)
135+
final_seed0 = env0.set_seed(0)
136+
tdreset0 = env0.reset()
137+
rollout0 = env0.rollout(max_steps=50)
138+
env0.close()
139+
del env0
140+
tds_reset.append(tdreset0)
141+
tds.append(rollout0)
142+
final_seed.append(final_seed0)
143+
144+
tdreset1, tdreset0 = tds_reset
145+
rollout0, rollout1 = tds
146+
final_seed0, final_seed1 = final_seed
150147

151148
assert_allclose_td(tdreset1, tdreset0)
152149
assert final_seed0 == final_seed1

0 commit comments

Comments
 (0)