openai / mujoco-py

MuJoCo is a physics engine for detailed, efficient rigid body simulations with contacts. mujoco-py allows using MuJoCo from Python 3.
Other
2.89k stars 813 forks source link

Mujoco can't find files when placed in a non-home directory: /opt/mujoco-py/mujoco_py/cymj.c:798:10: fatal error: mjmodel.h: No such file or directory #784

Open Deepakgthomas opened 10 months ago

Deepakgthomas commented 10 months ago

Describe the bug I am using Docker and I'd like to store my Mujoco files in a non home directory. To ensure that Mujoco can find my files I did the following -

ENV PATH="/opt/.mujoco/mjpro150:$PATH"
ENV MJLIB_PATH /opt/.mujoco/mjpro150/bin/libmujoco150.so
ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/opt/.mujoco/mjpro150/bin
ENV MUJOCO_PY_MJPRO_PATH /opt/.mujoco/mjpro150/
ENV MUJOCO_PY_MUJOCO_PATH /opt/.mujoco/mjpro150/
ENV MUJOCO_PY_MJKEY_PATH /opt/.mujoco/mjkey.txt

Here is my entire Dockerfile for your reference -

FROM ubuntu:22.04

WORKDIR /app

SHELL ["/bin/bash", "-c"] 

RUN echo "Hello World!"
RUN apt-get update && apt-get install -y \
    libosmesa6-dev \
    sudo \
    wget \
    curl \
    unzip \
    gcc \
    git \
    g++ \
    &&  apt-get install \
    libosmesa6-dev \
    && rm -rf /var/lib/apt/lists/*

ENV DEBIAN_FRONTEND=noninteractive

ENV PATH="/miniconda3/bin:${PATH}"
ARG PATH="/miniconda3/bin:${PATH}"

RUN cd / \
    && mkdir -p /miniconda3 \
    && wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /miniconda3/miniconda.sh \
    && bash /miniconda3/miniconda.sh -b -u -p /miniconda3 \
    && /miniconda3/bin/conda init bash \
    && source ~/.bashrc \
    && conda init \
    && conda create -y -n myenv python=3.8 \
    && conda update -y conda

ENV PATH="/opt/.mujoco/mjpro150:$PATH"
ENV MJLIB_PATH /opt/.mujoco/mjpro150/bin/libmujoco150.so
ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/opt/.mujoco/mjpro150/bin
ENV MUJOCO_PY_MJPRO_PATH /opt/.mujoco/mjpro150/
ENV MUJOCO_PY_MUJOCO_PATH /opt/.mujoco/mjpro150/
ENV MUJOCO_PY_MJKEY_PATH /opt/.mujoco/mjkey.txt
RUN cd / \
    && wget https://roboti.us/download/mjpro150_linux.zip \
    && unzip mjpro150_linux.zip \
    && mkdir -p /opt/.mujoco \
    && mv mjpro150 /opt/.mujoco \
    && wget https://roboti.us/file/mjkey.txt \
    && mv mjkey.txt /opt/.mujoco \
    && rm mjpro150_linux.zip

RUN cd /miniconda3/envs/myenv/lib/ && mv libstdc++.so.6 libstdc++.so.6.old && ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 libstdc++.so.6

SHELL ["conda", "run", "-n", "myenv", "/bin/bash", "-c"]
EXPOSE 5003

RUN cd /opt \
    && git clone https://github.com/openai/mujoco-py.git \
    && cd mujoco-py \
    && git checkout 1.50.1.0 \
    && pip install --no-cache-dir -r requirements.txt \
    && pip install --no-cache-dir -r requirements.dev.txt \
    && pip install "cython<3"
RUN cd /opt/mujoco-py \
    && python setup.py build install

This is the error that I get -

6.606 /opt/mujoco-py/mujoco_py/cymj.c:798:10: fatal error: mjmodel.h: No such file or directory
6.606   798 | #include "mjmodel.h"
6.606       |          ^~~~~~~~~~~
6.606 compilation terminated.
6.606 warning: mujoco_py/generated/../pxd/mjmodel.pxd:315:8: 'mjSENS_BALLQUAT' redeclared 
6.606 warning: mujoco_py/generated/../pxd/mjmodel.pxd:316:8: 'mjSENS_BALLANGVEL' redeclared 
6.606 warning: mujoco_py/generated/../pxd/mjmodel.pxd:319:8: 'mjSENS_FRAMEPOS' redeclared 
6.606 warning: mujoco_py/generated/../pxd/mjmodel.pxd:320:8: 'mjSENS_FRAMEQUAT' redeclared 
6.606 warning: mujoco_py/generated/../pxd/mjmodel.pxd:321:8: 'mjSENS_FRAMEXAXIS' redeclared 
6.606 warning: mujoco_py/generated/../pxd/mjmodel.pxd:322:8: 'mjSENS_FRAMEYAXIS' redeclared 
6.606 warning: mujoco_py/generated/../pxd/mjmodel.pxd:323:8: 'mjSENS_FRAMEZAXIS' redeclared 
6.606 warning: mujoco_py/generated/../pxd/mjmodel.pxd:324:8: 'mjSENS_FRAMELINVEL' redeclared 
6.606 warning: mujoco_py/generated/../pxd/mjmodel.pxd:325:8: 'mjSENS_FRAMEANGVEL' redeclared 
6.606 warning: mujoco_py/generated/../pxd/mjmodel.pxd:326:8: 'mjSENS_FRAMELINACC' redeclared 
6.606 warning: mujoco_py/generated/../pxd/mjmodel.pxd:327:8: 'mjSENS_FRAMEANGACC' redeclared 
6.606 warning: mujoco_py/generated/../pxd/mjmodel.pxd:330:8: 'mjSENS_SUBTREECOM' redeclared 
6.606 warning: mujoco_py/generated/../pxd/mjmodel.pxd:331:8: 'mjSENS_SUBTREELINVEL' redeclared 
6.606 warning: mujoco_py/generated/../pxd/mjmodel.pxd:332:8: 'mjSENS_SUBTREEANGMOM' redeclared 
6.606 warning: mujoco_py/generated/../pxd/mjmodel.pxd:335:8: 'mjSENS_USER' redeclared 
6.606 warning: mujoco_py/generated/../pxd/mjmodel.pxd:339:8: 'mjSTAGE_NONE' redeclared 
6.606 warning: mujoco_py/generated/../pxd/mjmodel.pxd:340:8: 'mjSTAGE_POS' redeclared 
6.606 warning: mujoco_py/generated/../pxd/mjmodel.pxd:341:8: 'mjSTAGE_VEL' redeclared 
6.606 warning: mujoco_py/generated/../pxd/mjmodel.pxd:342:8: 'mjSTAGE_ACC' redeclared 
6.606 warning: mujoco_py/generated/../pxd/mjmodel.pxd:346:8: 'mjDATATYPE_REAL' redeclared 
6.606 warning: mujoco_py/generated/../pxd/mjmodel.pxd:347:8: 'mjDATATYPE_POSITIVE' redeclared 
6.606 warning: mujoco_py/generated/../pxd/mjmodel.pxd:348:8: 'mjDATATYPE_AXIS' redeclared 
6.606 warning: mujoco_py/generated/../pxd/mjmodel.pxd:349:8: 'mjDATATYPE_QUAT' redeclared 
6.606 error: command '/usr/bin/gcc' failed with exit code 1

I am a bit of a newbie so please pardon my silly mistakes.