dppo/slurm/dev_tests/test_mujoco_override.sh
ys1087@partner.kit.edu 826b55a2d2 Integrate HoReKa Intel compiler fix for mujoco-py
- Add HoReKa-specific MuJoCo compilation fix to install script
- Pin compatible Cython version (0.29.37)
- Create fix_mujoco_compilation.py helper script
- Document Intel compiler override in README
- Update test script to use integrated fix
- Addresses Intel OneAPI compiler flag incompatibility with GCC
2025-08-27 16:09:13 +02:00

88 lines
2.7 KiB
Bash

#!/bin/bash
#SBATCH --job-name=dppo_mujoco_override
#SBATCH --account=hk-project-p0022232
#SBATCH --partition=dev_accelerated
#SBATCH --gres=gpu:1
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=1
#SBATCH --cpus-per-task=8
#SBATCH --time=00:30:00
#SBATCH --mem=24G
#SBATCH --output=logs/dppo_mujoco_override_%j.out
#SBATCH --error=logs/dppo_mujoco_override_%j.err
# Load only CUDA for OpenGL support
module load devel/cuda/12.4
cd $SLURM_SUBMIT_DIR
source .venv/bin/activate
# Override ALL compiler settings completely
export CC=/usr/bin/gcc
export CXX=/usr/bin/g++
export CPP=/usr/bin/cpp
# Clear ALL Intel-specific environment variables
unset CFLAGS
unset CXXFLAGS
unset FFLAGS
unset LDFLAGS
unset OPT
# Set clean GCC-only flags that override everything
export CFLAGS="-std=c99 -O2 -fPIC -w"
export CXXFLAGS="-std=c++11 -O2 -fPIC -w"
export LDFLAGS=""
# Clean mujoco-py completely first
echo "Cleaning all mujoco-py artifacts..."
rm -rf .venv/lib/python3.10/site-packages/mujoco_py/generated/
rm -rf .venv/lib/python3.10/site-packages/mujoco_py/.eggs/
rm -rf .venv/lib/python3.10/site-packages/mujoco_py/build/
find .venv/lib/python3.10/site-packages/mujoco_py/ -name "*.so" -delete
find .venv/lib/python3.10/site-packages/mujoco_py/ -name "*.pyc" -delete
# Set MuJoCo environment
export MUJOCO_PY_MUJOCO_PATH=/home/hk-project-robolear/ys1087/.mujoco/mujoco210
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/hk-project-robolear/ys1087/.mujoco/mujoco210/bin:/usr/lib/nvidia
export MUJOCO_GL=egl
# Test with direct Python override of distutils compiler flags
echo "Testing mujoco-py with aggressive compiler flag override..."
python -c "
import os
import distutils.util
import sysconfig
# Override Python's built-in compiler settings
os.environ['CC'] = '/usr/bin/gcc'
os.environ['CXX'] = '/usr/bin/g++'
os.environ['CFLAGS'] = '-std=c99 -O2 -fPIC -w'
os.environ['CXXFLAGS'] = '-std=c++11 -O2 -fPIC -w'
# Hack: Override sysconfig to remove Intel flags
import sys
def patched_get_config_var(name):
if name in ['CFLAGS', 'BASECFLAGS', 'PY_CFLAGS', 'PY_CORE_CFLAGS', 'CCSHARED']:
return '-std=c99 -O2 -fPIC -w'
elif name in ['CXXFLAGS', 'CXX']:
return '-std=c++11 -O2 -fPIC -w'
elif name == 'CC':
return '/usr/bin/gcc'
else:
# Call the original function for other variables
return sysconfig._original_get_config_var(name)
# Store original and patch
sysconfig._original_get_config_var = sysconfig.get_config_var
sysconfig.get_config_var = patched_get_config_var
print('Attempting mujoco_py import with patched sysconfig...')
try:
import mujoco_py
print('SUCCESS: mujoco_py compiled and imported successfully!')
except Exception as e:
print(f'FAILED: {e}')
import traceback
traceback.print_exc()
"