Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac M1 conda env #30

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Mac M1 conda env #30

wants to merge 1 commit into from

Conversation

edwhu
Copy link

@edwhu edwhu commented Mar 17, 2023

Hello,

I wanted to get this running on my M1 laptop for local development. The installation process deviated quite a bit from the README.

In particular, I had to setup tensorflow and jax differently than the README workflow. It went something like this:

conda create -n dreamerv3 python=3.8
conda activate dreamerv3

conda install -c apple tensorflow-deps
conda install jax -c conda-forge
pip install tensorflow-macos tensorflow_probability

pip install -r requirements.txt # comment out tensorflow-cpu in requirements.txt first.

I verified this environment by running example.py and by repeating the whole process again (conda installation and running example.py).

To make things easier for future users, I exported the conda env file. Then they don't need to manually install the conda dependencies and edit the requirements.txt.

Perhaps this will be useful for others?

@giteverything
Copy link

giteverything commented Apr 3, 2023

really nice work! When I run the example.py, some error occurs:

RuntimeError: Unknown backend: 'gpu' requested, but no platforms that are instances of gpu are present. Platforms
present are: interpreter,cpu

any idea how to fix it?

more details here:
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /Users/arthur/src/dreamerv3/example.py:53 in │
│ │
│ 50 │
│ 51 │
│ 52 if name == 'main': │
│ ❱ 53 main() │
│ 54 │
│ │
│ /Users/arthur/src/dreamerv3/example.py:42 in main │
│ │
│ 39 env = dreamerv3.wrap_env(env, config) │
│ 40 env = embodied.BatchEnv([env], parallel=False) │
│ 41 │
│ ❱ 42 agent = dreamerv3.Agent(env.obs_space, env.act_space, step, config) │
│ 43 replay = embodied.replay.Uniform( │
│ 44 │ config.batch_length, config.replay_size, logdir / 'replay') │
│ 45 args = embodied.Config( │
│ │
│ /Users/arthur/src/dreamerv3/dreamerv3/jaxagent.py:20 in init
│ │
│ 17 │ configs = agent_cls.configs │
│ 18 │ inner = agent_cls │
│ 19 │ def init(self, *args, **kwargs): │
│ ❱ 20 │ super().init(agent_cls, *args, **kwargs) │
│ 21 return Agent │
│ 22 │
│ 23 │
│ │
│ /Users/arthur/src/dreamerv3/dreamerv3/jaxagent.py:35 in init
│ │
│ 32 │ self.agent = agent_cls(obs_space, act_space, step, config, name='agent') │
│ 33 │ self.rng = np.random.default_rng(config.seed) │
│ 34 │ │
│ ❱ 35 │ available = jax.devices(self.config.platform) │
│ 36 │ self.policy_devices = [available[i] for i in self.config.policy_devices] │
│ 37 │ self.train_devices = [available[i] for i in self.config.train_devices] │
│ 38 │ self.single_device = (self.policy_devices == self.train_devices) and ( │
│ │
│ /Users/arthur/miniconda3/envs/dreamerv3/lib/python3.8/site-packages/jax/_src/lib/xla_bridge.py:4 │
│ 83 in devices │
│ │
│ 480 Returns: │
│ 481 │ List of Device subclasses. │
│ 482 """ │
│ ❱ 483 return get_backend(backend).devices() │
│ 484 │
│ 485 │
│ 486 def default_backend() -> str: │
│ │
│ /Users/arthur/miniconda3/envs/dreamerv3/lib/python3.8/site-packages/jax/_src/lib/xla_bridge.py:4 │
│ 25 in get_backend │
│ │
│ 422 │
│ 423 @lru_cache(maxsize=None) # don't use util.memoize because there is no X64 dependence. │
│ 424 def get_backend(platform=None): │
│ ❱ 425 return _get_backend_uncached(platform) │
│ 426 │
│ 427 │
│ 428 def get_device_backend(device=None): │
│ │
│ /Users/arthur/miniconda3/envs/dreamerv3/lib/python3.8/site-packages/jax/_src/lib/xla_bridge.py:4 │
│ 11 in _get_backend_uncached │
│ │
│ 408 │
│ 409 bs = backends() │
│ 410 if platform is not None: │
│ ❱ 411 │ platform = canonicalize_platform(platform) │
│ 412 │ backend = bs.get(platform, None) │
│ 413 │ if backend is None: │
│ 414 │ if platform in _backends_errors: │
│ │
│ /Users/arthur/miniconda3/envs/dreamerv3/lib/python3.8/site-packages/jax/_src/lib/xla_bridge.py:2 │
│ 94 in canonicalize_platform │
│ │
│ 291 for p in platforms: │
│ 292 │ if p in b.keys(): │
│ 293 │ return p │
│ ❱ 294 raise RuntimeError(f"Unknown backend: '{platform}' requested, but no " │
│ 295 │ │ │ │ │ f"platforms that are instances of {platform} are present. " │
│ 296 │ │ │ │ │ "Platforms present are: " + ",".join(b.keys())) │
│ 297 │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
RuntimeError: Unknown backend: 'gpu' requested, but no platforms that are instances of gpu are present. Platforms
present are: interpreter,cpu

@edwhu
Copy link
Author

edwhu commented Apr 3, 2023

Hi, if you are on M1 mac, there is no GPU as the error message says. Just specify cpu instead of gpu in the config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants