Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions easybuild/easyconfigs/m/MuJoCo/MuJoCo-3.3.0-GCCcore-13.2.0.eb
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
easyblock = 'CMakeMake'

name = 'MuJoCo'
version = '3.3.0'

homepage = 'https://mujoco.org/'
description = """MuJoCo stands for Multi-Joint dynamics with Contact. It is a general purpose
physics engine that aims to facilitate research and development in robotics,
biomechanics, graphics and animation, machine learning, and other areas which
demand fast and accurate simulation of articulated structures interacting with
their environment."""

toolchain = {'name': 'GCCcore', 'version': '13.2.0'}

source_urls = ['https://github.com/google-deepmind/mujoco/archive/refs/tags']

# Sources otherwise downloaded by CMake FetchContent
local_extract_cmd_tmpl = "mkdir -p _deps/{0} && tar --strip-components=1 -C _deps/{0} -xf %s"
sources = [
'%(version)s.tar.gz',
# Hashes from MUJOCO_DEP_VERSION_* in cmake/MujocoDependencies.cmake
{
'source_urls': ['https://github.com/danfis/libccd/archive'],
'filename': '7931e764a19ef6b21b443376c699bbc9c6d4fba8.tar.gz',
'extract_cmd': local_extract_cmd_tmpl.format('ccd-src'),
},
{
'source_urls': ['https://github.com/lvandeve/lodepng/archive'],
'filename': 'b4ed2cd7ecf61d29076169b49199371456d4f90b.tar.gz',
'extract_cmd': local_extract_cmd_tmpl.format('lodepng-src'),
},
{
'source_urls': ['https://github.com/aparis69/MarchingCubeCpp/archive'],
'filename': 'f03a1b3ec29b1d7d865691ca8aea4f1eb2c2873d.tar.gz',
'extract_cmd': local_extract_cmd_tmpl.format('marchingcubecpp-src'),
},
]
patches = [
'MuJoCo-3.3.0_use_eb_deps.patch',
]
checksums = [
{'3.3.0.tar.gz': '608cd202ac5066096fdc7e5adb322aca2fe7b4d118543a7c4b54dc183a6b3b54'},
{'7931e764a19ef6b21b443376c699bbc9c6d4fba8.tar.gz':
'479994a86d32e2effcaad64204142000ee6b6b291fd1859ac6710aee8d00a482'},
{'b4ed2cd7ecf61d29076169b49199371456d4f90b.tar.gz':
'b67e466ba659c07ac775d07dbd97af319cde449ce14abed9ae596df29d888603'},
{'f03a1b3ec29b1d7d865691ca8aea4f1eb2c2873d.tar.gz':
'227c10b2cffe886454b92a0e9ef9f0c9e8e001d00ea156cc37c8fc43055c9ca6'},
{'MuJoCo-3.3.0_use_eb_deps.patch': 'd60c4f78f5f59c8fc43c1e9e93580806b86bcd17507c1030e831bece17fbd710'},
]

builddependencies = [
('binutils', '2.40'),
('CMake', '3.27.6'),
('googlebenchmark', '1.9.1'),
('googletest', '1.14.0'),
]
dependencies = [
('Abseil', '20240116.1'),
('GLFW', '3.4'),
('Qhull', '2020.2'),
('SdfLib', '20250125'),
('tinyobjloader', '2.0.0rc13'),
('TinyXML-2', '11.0.0'),
('X11', '20231019'),
]

build_shared_libs = True
# Avoid test failure due to different vectorization between C/C++
# see https://github.com/google-deepmind/mujoco/issues/2515
preconfigopts = 'CXXFLAGS="$CXXFLAGS -ffp-contract=off" '

configopts = ' '.join([
'-DMUJOCO_SAMPLES_USE_SYSTEM_GLFW=ON',
'-DMUJOCO_SIMULATE_USE_SYSTEM_GLFW=ON',
'-DMUJOCO_TEST_PYTHON_UTIL=OFF',
'-DFETCHCONTENT_FULLY_DISCONNECTED=ON',
'-DFETCHCONTENT_BASE_DIR=%(builddir)s/_deps',
])

runtest = True

sanity_check_paths = {
'files': ['bin/basic', 'bin/record', 'bin/simulate',
'lib/libmujoco.%s' % SHLIB_EXT],
'dirs': ['bin', 'include', 'share/mujoco/model'],
}

sanity_check_commands = ['basic']

moduleclass = 'phys'
127 changes: 127 additions & 0 deletions easybuild/easyconfigs/m/MuJoCo/MuJoCo-3.3.0_use_eb_deps.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
Use "System packages" aka our installed modules

Author: Alexander Grund (TU Dresden)

diff -ur mujoco-orig/cmake/MujocoDependencies.cmake mujoco-3.3.0/cmake/MujocoDependencies.cmake
--- mujoco-orig/cmake/MujocoDependencies.cmake 2025-03-18 17:34:53.241471506 +0100
+++ mujoco-3.3.0/cmake/MujocoDependencies.cmake 2025-03-18 17:36:46.337021313 +0100
@@ -128,9 +128,9 @@

findorfetch(
USE_SYSTEM_PACKAGE
- OFF
+ ON
PACKAGE_NAME
- qhull
+ Qhull
LIBRARY_NAME
qhull
GIT_REPO
@@ -138,21 +138,26 @@
GIT_TAG
${MUJOCO_DEP_VERSION_qhull}
TARGETS
- qhull
+ Qhull::qhull
EXCLUDE_FROM_ALL
)
# MuJoCo includes a file from libqhull_r which is not exported by the qhull include directories.
# Add it to the target.
-target_include_directories(
- qhullstatic_r INTERFACE $<BUILD_INTERFACE:${qhull_SOURCE_DIR}/src/libqhull_r>
-)
-target_compile_options(qhullstatic_r PRIVATE ${MUJOCO_MACOS_COMPILE_OPTIONS})
-target_link_options(qhullstatic_r PRIVATE ${MUJOCO_MACOS_LINK_OPTIONS})
+ add_library(qhullstatic_r INTERFACE)
+ set_target_properties(qhullstatic_r PROPERTIES INTERFACE_LINK_LIBRARIES Qhull::qhull_r)
+
+ # Workaround as headers are installed in <prefix>/include/libqhull_r/something.h
+ # but mujoco include them as #include <something.h>
+ get_property(qhull_include_dirs TARGET Qhull::qhull_r PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
+ foreach(qhull_include_dir IN LISTS qhull_include_dirs)
+ target_include_directories(qhullstatic_r INTERFACE ${qhull_include_dirs}/libqhull_r)
+ endforeach()
+ target_include_directories(qhullstatic_r INTERFACE )

set(tinyxml2_BUILD_TESTING OFF)
findorfetch(
USE_SYSTEM_PACKAGE
- OFF
+ ON
PACKAGE_NAME
tinyxml2
LIBRARY_NAME
@@ -162,15 +167,13 @@
GIT_TAG
${MUJOCO_DEP_VERSION_tinyxml2}
TARGETS
- tinyxml2
+ tinyxml2::tinyxml2
EXCLUDE_FROM_ALL
)
-target_compile_options(tinyxml2 PRIVATE ${MUJOCO_MACOS_COMPILE_OPTIONS})
-target_link_options(tinyxml2 PRIVATE ${MUJOCO_MACOS_LINK_OPTIONS})

findorfetch(
USE_SYSTEM_PACKAGE
- OFF
+ ON
PACKAGE_NAME
tinyobjloader
LIBRARY_NAME
@@ -183,15 +186,16 @@
tinyobjloader
EXCLUDE_FROM_ALL
)
+add_library(tinyobjloader ALIAS tinyobjloader::tinyobjloader)

option(SDFLIB_USE_ASSIMP OFF)
option(SDFLIB_USE_OPENMP OFF)
option(SDFLIB_USE_ENOKI OFF)
findorfetch(
USE_SYSTEM_PACKAGE
- OFF
+ ON
PACKAGE_NAME
- sdflib
+ SdfLib
LIBRARY_NAME
sdflib
GIT_REPO
@@ -202,8 +206,7 @@
SdfLib
EXCLUDE_FROM_ALL
)
-target_compile_options(SdfLib PRIVATE ${MUJOCO_MACOS_COMPILE_OPTIONS})
-target_link_options(SdfLib PRIVATE ${MUJOCO_MACOS_LINK_OPTIONS})
+add_library(SdfLib ALIAS SdfLib::SdfLib)

set(ENABLE_DOUBLE_PRECISION ON)
set(CCD_HIDE_ALL_SYMBOLS ON)
@@ -249,7 +252,7 @@
set(ABSL_BUILD_TESTING OFF)
findorfetch(
USE_SYSTEM_PACKAGE
- OFF
+ ON
PACKAGE_NAME
absl
LIBRARY_NAME
@@ -276,7 +279,7 @@

findorfetch(
USE_SYSTEM_PACKAGE
- OFF
+ ON
PACKAGE_NAME
GTest
LIBRARY_NAME
@@ -310,7 +313,7 @@

findorfetch(
USE_SYSTEM_PACKAGE
- OFF
+ ON
PACKAGE_NAME
benchmark
LIBRARY_NAME
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
easyblock = 'PythonPackage'

name = 'python-mujoco'
version = '3.3.0'

homepage = 'https://www.mujoco.org'
description = """
This package is the canonical Python bindings for the MuJoCo physics engine.
The mujoco package provides direct access to raw MuJoCo C API functions, structs,
constants, and enumerations. Structs are provided as Python classes, with
Pythonic initialization and deletion semantics.
"""

toolchain = {'name': 'gfbf', 'version': '2023b'}

builddependencies = [
('Eigen', '3.4.0'),
('pybind11', '2.11.1'),
('CMake', '3.27.6'),
]

dependencies = [
('Python', '3.11.5'),
('absl-py', '2.1.0'),
('etils', '1.12.2'),
('python-glfw', '2.8.0'),
('MuJoCo', '3.3.0'),
('PyOpenGL', '3.1.9'),
('SciPy-bundle', '2023.11'),
]


options = {'modulename': 'mujoco'}
source_urls = ['https://pypi.python.org/packages/source/m/mujoco']
local_extract_cmd_tmpl = "mkdir -p %(builddir)s/_deps/{0} && tar --strip-components=1 -C %(builddir)s/_deps/{0} -xf %s"
sources = [
'mujoco-%(version)s.tar.gz',
# Hashes from MUJOCO_DEP_VERSION_* in mujoco/simulate/CMakeLists.txt
{
'source_urls': ['https://github.com/lvandeve/lodepng/archive'],
'filename': 'b4ed2cd7ecf61d29076169b49199371456d4f90b.tar.gz',
'extract_cmd': local_extract_cmd_tmpl.format('lodepng-src'),
},
]
patches = [
'python-mujoco-3.3.0_fix-ogl-use-after-free.patch',
'python-mujoco-3.3.0_use_eb_deps.patch',
]
checksums = [
{'mujoco-3.3.0.tar.gz': '0fb12ab715bc2b6d2394a6330b8c3a1dd95b0f3ba812bfe4f6c91e0a1ca3ad0f'},
{'b4ed2cd7ecf61d29076169b49199371456d4f90b.tar.gz':
'b67e466ba659c07ac775d07dbd97af319cde449ce14abed9ae596df29d888603'},
{'python-mujoco-3.3.0_fix-ogl-use-after-free.patch':
'a0098aa9633ec3849ded3d886c957c5802a872f74970bdc5456020cd6ccc86d9'},
{'python-mujoco-3.3.0_use_eb_deps.patch': 'bed192acb9aab3d9dbd674c0faafc981a92791385dac300cca5ca80d7ca04991'},
]

local_cmake_opts = ' '.join([
'-DFETCHCONTENT_FULLY_DISCONNECTED=ON',
'-DFETCHCONTENT_BASE_DIR=%(builddir)s/_deps',
'-DMUJOCO_PYTHON_USE_SYSTEM_PYBIND11=ON',
'-DMUJOCO_SIMULATE_USE_SYSTEM_MUJOCO=ON',
'-DMUJOCO_SIMULATE_USE_SYSTEM_GLFW=ON',
])

prebuildopts = 'MUJOCO_PATH="$EBROOTMUJOCO" MUJOCO_PLUGIN_PATH="$EBROOTMUJOCO/bin/mujoco_plugin"'
prebuildopts += f' MUJOCO_CMAKE_ARGS="{local_cmake_opts}"'
preinstallopts = prebuildopts
Comment on lines +66 to +68
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here we could define preinstallopts directly wihtout prebuildopts

Copy link
Copy Markdown
Contributor Author

@Flamefire Flamefire Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah the PythonPackage easyblock is weird. IMO the best idea is to define both (to the same value) so it is clear that the value is used.

But yes, technically preinstallopts is enough


moduleclass = 'lib'
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Fix an error during shutdown:

> Exception ignored in: <function GLContext.__del__ at 0x7f816b140cc0>
> ...
> OpenGL.raw.EGL._errors.EGLError: <exception str() failed>

See https://github.com/google-deepmind/mujoco/pull/2510

Author: Alexander Grund (TU Dresden)

diff --git a/python/mujoco/egl/__init__.py b/python/mujoco/egl/__init__.py
index 832c11081c..2a9a4468a2 100644
--- a/python/mujoco/egl/__init__.py
+++ b/python/mujoco/egl/__init__.py
@@ -65,6 +65,12 @@ def create_initialized_egl_device_display():
EGL_DISPLAY = None


+def _free_display():
+ global EGL_DISPLAY
+ EGL.eglTerminate(EGL_DISPLAY)
+ EGL_DISPLAY = None
+
+
EGL_ATTRIBUTES = (
EGL.EGL_RED_SIZE, 8,
EGL.EGL_GREEN_SIZE, 8,
@@ -99,7 +105,7 @@ def __init__(self, max_width, max_height):
"driver does not support the PLATFORM_DEVICE extension, which is "
"required for creating a headless rendering context."
)
- atexit.register(EGL.eglTerminate, EGL_DISPLAY)
+ atexit.register(_free_display)
EGL.eglChooseConfig(
EGL_DISPLAY,
EGL_ATTRIBUTES,
@@ -125,7 +131,7 @@ def make_current(self):
def free(self):
"""Frees resources associated with this context."""
global EGL_DISPLAY
- if self._context:
+ if EGL_DISPLAY and self._context:
current_context = EGL.eglGetCurrentContext()
if current_context and self._context.address == current_context.address:
EGL.eglMakeCurrent(EGL_DISPLAY, EGL.EGL_NO_SURFACE,
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Use EasyBuild provided dependencies
Author (update): Alexander Grund (TU Dresden)
--- mujoco-3.1.4.orig/mujoco/CMakeLists.txt 2024-04-17 15:42:21.449694000 +0200
+++ mujoco-3.1.4/mujoco/CMakeLists.txt 2024-04-17 15:43:56.347482395 +0200
@@ -132,7 +132,7 @@
set(MUJOCO_PYTHON_ABSL_TARGETS absl::core_headers absl::flat_hash_map absl::span)
findorfetch(
USE_SYSTEM_PACKAGE
- OFF
+ ON
PACKAGE_NAME
absl
LIBRARY_NAME
@@ -165,7 +165,7 @@
add_compile_definitions(EIGEN_MPL2_ONLY)
findorfetch(
USE_SYSTEM_PACKAGE
- OFF
+ ON
PACKAGE_NAME
Eigen3
LIBRARY_NAME