huaweinoah/smarts is a simulation platform for reinforcement learning (RL) and multi-agent research on autonomous driving. Its focus is on realistic and diverse interactions. It is part of the XingTian suite of RL platforms from Huawei Noah's Ark Lab.
Check out the paper at SMARTS: Scalable Multi-Agent Reinforcement Learning Training School for Autonomous Driving for background on some of the project goals.
pythonimport gym from smarts.core.agent_interface import AgentInterface, AgentType from smarts.core.agent import Agent from smarts.zoo.agent_spec import AgentSpec class SimpleAgent(Agent): def act(self, obs): return "keep_lane" agent_spec = AgentSpec( interface=AgentInterface.from_type(AgentType.Laner, max_episode_steps=None), agent_builder=SimpleAgent, ) agent_specs = { "Agent-007": agent_spec, "Agent-008": agent_spec, } env = gym.make( "smarts.env:hiway-v0", scenarios=["scenarios/sumo/loop"], agent_specs=agent_specs, ) agents = { agent_id: agent_spec.build_agent() for agent_id, agent_spec in agent_specs.items() } observations = env.reset() for _ in range(1000): agent_actions = { agent_id: agents[agent_id].act(agent_obs) for agent_id, agent_obs in observations.items() } observations, _, _, _ = env.step(agent_actions)
Documentation is available at smarts.readthedocs.io.
bashgit clone [***] cd <path/to/SMARTS> # For Mac OS X users, ensure XQuartz is pre-installed. # Install the system requirements. You may use the `-y` option to enable automatic assumption of "yes" to all prompts to avoid timeout from waiting for user input. bash utils/setup/install_deps.sh # Setup virtual environment. Presently at least Python 3.7 and higher is officially supported. python3.7 -m venv .venv # Enter virtual environment to install dependencies. source .venv/bin/activate # Upgrade pip. pip install --upgrade pip # Install smarts with extras as needed. Extras include the following: # `camera-obs` - needed for rendering camera sensor observations, and for testing. # `test` - needed for testing. # `train` - needed for RL training and testing. pip install -e '.[camera-obs,test,train]' # Run sanity-test and verify they are passing. # If tests fail, check './sanity_test_result.xml' for test report. make sanity-test
Use the scl command to run SMARTS together with it's supporting processes.
To run the default example, firstly build the scenario scenarios/sumo/loop.
bashscl scenario build --clean scenarios/sumo/loop
Then, run a single-agent SMARTS simulation with Envision display and loop scenario.
bashscl run --envision examples/single_agent.py scenarios/sumo/loop
The --envision flag runs the Envision server which displays the simulation visualization. See ./envision/README.md for more information on Envision, SMARTS's front-end visualization tool.
After executing the above command, visit http://localhost:8081/ to view the experiment.
Several example scripts are provided in examples folder, as well as a handful of scenarios in scenarios folder. You can create your own scenarios using the Scenario Studio. Below is the generic command to run and visualize one of the example scripts with a scenario.
bashscl run --envision <examples/path> <scenarios/path>
Illustration of various ways to use SMARTS.
SMARTS provides a command-line tool to interact with scenario studio and Envision.
bashscl COMMAND SUBCOMMAND [OPTIONS] [ARGS]...
Commands:
Subcommands of scenario:
Subcommands of envision:
Subcommands of zoo:
Subcommands of run:
run directly to simulate as shown above.bash# Start envision and serve scenario assets out of ./scenarios scl envision start --scenarios ./scenarios # Build all scenarios under given directories scl scenario build-all ./scenarios ./eval_scenarios # Rebuild a single scenario, replacing any existing generated assets scl scenario build --clean scenarios/sumo/loop # Clean generated scenario artifacts scl scenario clean scenarios/sumo/loop
Use the Visdom integration to easily visualize the observations.
Firstly, start the Visdom server in a terminal.
bashvisdom # Open the printed URL in a browser.
Secondly, in a separate terminal, run SMARTS simulation. Enable Visdom in the environment by setting visdom=True. For example:
pythonenv = gym.make( "smarts.env:hiway-v0", scenarios=["scenarios/sumo/loop"], agent_specs=agent_specs, visdom=True, )
Below is a sample visualization of an agent's camera sensor observations.
(Left) Drivable area grid map. (Center) Occupancy grid map. (Right) Top-down RGB image.
Run SMARTS with PyMARL.
bashgit clone ***:ying-wen/pymarl.git ln -s your-project/scenarios ./pymarl/scenarios cd pymarl # Setup virtual environment. python3 -m venv .venv source .venv/bin/activate pip install -r requirements.txt python src/main.py --config=qmix --env-config=smarts
Run SMARTS with MALib.
bashgit clone ***:ying-wen/malib.git ln -s your-project/scenarios ./malib/scenarios cd malib # Setup virtual environment. python3 -m venv .venv source .venv/bin/activate pip install -r requirements.txt python examples/run_smarts.py --algo SAC --scenario ./scenarios/sumo/loop --n_agents 5
SMARTS docker images are hosted at dockerhub.
bash$ cd </path/to/SMARTS> $ docker run --rm -it -v $PWD:/src -p 8081:8081 huaweinoah/smarts:<version> # E.g. docker run --rm -it -v $PWD:/src -p 8081:8081 huaweinoah/smarts:v0.5.1 # If visualization is needed, run Envision server in the background. $ scl envision start -s ./scenarios -p 8081 & # Build the scenario. # This step is required on the first time, and whenever the scenario is modified. $ scl scenario build scenarios/sumo/loop --clean # Run an example. # Add --headless if visualisation is not needed. $ python examples/single_agent.py scenarios/sumo/loop # Visit http://localhost:8081 in the host machine to see the running simulation in Envision.
bash$ cd </path/to/SMARTS> # Build container from definition file. $ sudo singularity build ./utils/singularity/smarts.sif ./utils/singularity/smarts.def # Use the container to build the required scenarios. $ singularity shell --containall --bind ../SMARTS:/src ./utils/singularity/smarts.sif # Inside the container Singularity> scl scenario build /src/scenarios/sumo/loop/ Singularity> exit # Then, run the container using one of the following methods. # 1. Run container in interactive mode. $ singularity shell --containall --bind ../SMARTS:/src ./utils/singularity/smarts.sif # Inside the container Singularity> python3.7 /src/examples/single_agent.py /src/scenarios/sumo/loop/ --headless # 2. Run commands within the container from the host system. $ singularity exec --containall --bind ../SMARTS:/src ./utils/singularity/smarts.sif python3.7 /src/examples/single_agent.py /src/scenarios/sumo/loop/ --headless # 3. Run container instance in the background. $ singularity instance start --containall --bind ../SMARTS:/src ./utils/singularity/smarts.sif smarts_train /src/examples/single_agent.py /src/scenarios/sumo/loop/ --headless
In most cases SMARTS debug logs are located at ~/.smarts. These can be helpful to diagnose problems.
SUMO might encounter problems during setup. Please look through the following for support for SUMO:
Please read how to create a bug report and then open an issue here.
Please read contributing.
If you use SMARTS in your research, please cite the paper. In BibTeX format:
bibtex@misc{zhou2020smarts, title={SMARTS: Scalable Multi-Agent Reinforcement Learning Training School for Autonomous Driving}, author={Ming Zhou and Jun Luo and Julian Villella and Yaodong Yang and David Rusu and Jiayu Miao and Weinan Zhang and Montgomery Alban and Iman Fadakar and Zheng Chen and Aurora Chongxi Huang and Ying Wen and Kimia Hassanzadeh and Daniel Graves and Dong Chen and Zhengbang Zhu and Nhat Nguyen and Mohamed Elsayed and Kun Shao and Sanjeevan Ahilan and Baokuan Zhang and Jiannan Wu and Zhengang Fu and Kasra Rezaee and Peyman Yadmellat and Mohsen Rohani and Nicolas Perez Nieves and Yihan Ni and Seyedershad Banijamali and Alexander Cowen Rivers and Zheng Tian and Daniel Palenicek and Haitham bou Ammar and Hongbo Zhang and Wulong Liu and Jianye Hao and Jun Wang}, url={[***]}, primaryClass={cs.MA}, booktitle={Proceedings of the 4th Conference on Robot Learning (CoRL)}, year={2020}, month={11} }
探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录认证访问私有仓库
在 Linux 系统配置镜像服务
在 Docker Desktop 配置镜像
Docker Compose 项目配置
Kubernetes 集群配置 Containerd
K3s 轻量级 Kubernetes 镜像加速
VS Code Dev Containers 配置
MacOS OrbStack 容器配置
在宝塔面板一键配置镜像
Synology 群晖 NAS 配置
飞牛 fnOS 系统配置镜像
极空间 NAS 系统配置服务
爱快 iKuai 路由系统配置
绿联 NAS 系统配置镜像
QNAP 威联通 NAS 配置
Podman 容器引擎配置
HPC 科学计算容器配置
ghcr、Quay、nvcr 等镜像仓库
无需登录使用专属域名
需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单
免费版仅支持 Docker Hub 访问,不承诺可用性和速度;专业版支持更多镜像源,保证可用性和稳定速度,提供优先客服响应。
专业版支持 docker.io、gcr.io、ghcr.io、registry.k8s.io、nvcr.io、quay.io、mcr.microsoft.com、docker.elastic.co 等;免费版仅支持 docker.io。
当返回 402 Payment Required 错误时,表示流量已耗尽,需要充值流量包以恢复服务。
通常由 Docker 版本过低导致,需要升级到 20.x 或更高版本以支持 V2 协议。
先检查 Docker 版本,版本过低则升级;版本正常则验证镜像信息是否正确。
使用 docker tag 命令为镜像打上新标签,去掉域名前缀,使镜像名称更简洁。
来自真实用户的反馈,见证轩辕镜像的优质服务