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

[Feature Request] Is it possible to run Mojo in a Docker container on M2 Max silicon? #588

Closed
1 task done
devforfu opened this issue Sep 7, 2023 · 7 comments
Closed
1 task done
Labels
enhancement New feature or request mojo Issues that are related to mojo mojo-repo Tag all issues with this label

Comments

@devforfu
Copy link

devforfu commented Sep 7, 2023

Review Mojo's priorities

What is your request?

I am trying to run Mojo locally on my M2 Max silicon desktop. I know that it is not supported natively, but I thought that running in Docker container would work. However, it looks like it is not the case. Running in a container derived from ubuntu:latest returns the error.

no packages found for the current target hardware - 
please run `modular host-info` and file a ticket at 
/~https://github.com/modularml/mojo with your hardware information

Here is my Dockerfile.

FROM ubuntu:latest

RUN apt-get update -y && \
  apt-get -y install curl gpg-agent && \
  apt-get install -y apt-transport-https && \
  keyring_location=/usr/share/keyrings/modular-installer-archive-keyring.gpg && \
  curl -1sLf 'https://dl.modular.com/bBNWiLZX5igwHXeu/installer/gpg.0E4925737A3895AD.key' |  gpg --dearmor >> ${keyring_location} && \
  curl -1sLf 'https://dl.modular.com/bBNWiLZX5igwHXeu/installer/config.deb.txt?distro=debian&codename=wheezy' > /etc/apt/sources.list.d/modular-installer.list && \
  apt-get update && \
  apt-get install -y modular

RUN modular auth <auth-token> && modular install mojo

Does it mean that running Mojo on M2 chips isn't possible at the moment? I don't have in-depth knowledge of how Docker containers work. So, I don't know if it is an expected behavior and this kind of virtualization is just not supported (should use a "real" Linux machine), or I am doing it wrong.

Thank you!

What is your motivation for this change?

It would be great to have an option of running Mojo in a Docker container for systems that don't support it natively.

Any other details?

No response

@devforfu devforfu added the enhancement New feature or request label Sep 7, 2023
@devforfu
Copy link
Author

devforfu commented Sep 7, 2023

There is a Dockerfile in the repo, but it also fails when I am trying to build a container. This time, however, with a different error.

=> ERROR [3/6] RUN curl -fsSL https://repo.anaconda.com/ [...]
------
[...]
9.642 qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory

@devforfu
Copy link
Author

devforfu commented Sep 7, 2023

Ok, it looks like that one is an issue of running Docker on an Apple's silicon. There is a solution that helped me to get to the next building stage. (Still running.) Here is the change to the Dockerfile.

FROM --platform=linux/amd64 ubuntu:20.04

@jackos
Copy link
Collaborator

jackos commented Sep 7, 2023

@devforfu it will fail when you try to run mojo as x86 emulation doesn't currently work, there's an open feature request for it here: #510 and we're actively working on native support.

For now you'll have to ssh to an x86-64 machine and install it there.

@jackos jackos closed this as completed Sep 7, 2023
@devforfu
Copy link
Author

devforfu commented Sep 7, 2023

@jackos ah, I see, thank you!

@HananyTolba
Copy link

I have just made available a docker imager with mojo ready for use : docker pull hananytolba/mojo:0.2.1 for use docker run -ti hananytolba/mojo:0.2.1 bash and inupt mojo

@getorca
Copy link

getorca commented Sep 13, 2023

same issue, using the dockerfile /~https://github.com/modularml/mojo/blob/main/examples/docker/Dockerfile.mojosdk and opening in a dev container in vs code sort of works. It can run the python cells but it fails on mojo cells.

eg from https://www.modular.com/blog/an-easy-introduction-to-mojo-for-python-programmers fails on the cell:

from Tensor import Tensor
from DType import DType
from Range import range
from SIMD import SIMD
from Math import sqrt
from Time import now

let n: Int = 10_000_000
var a = Tensor[DType.float64](n)
var b = Tensor[DType.float64](n)

for i in range(n):
    a[i] = anp[i].to_float64()
    b[i] = bnp[i].to_float64()

with:

error: Expression [7]:23:1: no viable expansions found
fn __lldb_expr__7(inout __mojo_repl_arg: __mojo_repl_context__):
^

Expression [7]:25:28:   call expansion failed - no concrete specializations
    __mojo_repl_expr_impl__(__mojo_repl_arg, __get_address_as_lvalue(__mojo_repl_arg.`secs`.load().address), __get_address_as_lvalue(__mojo_repl_arg.`python_numpy_dist`.load().address), __get_address_as_lvalue(__mojo_repl_arg.`___lldb_expr_failed`.load().address), __get_address_as_lvalue(__mojo_repl_arg.`python_naive_dist`.load().address), __get_address_as_lvalue(__mojo_repl_arg.`time`.load().address), __get_address_as_lvalue(__mojo_repl_arg.`print_formatter`.load().address), __get_address_as_lvalue(__mojo_repl_arg.`np`.load().address), __get_address_as_lvalue(__mojo_repl_arg.`n`.load().address), __get_address_as_lvalue(__mojo_repl_arg.`bnp`.load().address), __get_address_as_lvalue(__mojo_repl_arg.`blist`.load().address), __get_address_as_lvalue(__mojo_repl_arg.`anp`.load().address), __get_address_as_lvalue(__mojo_repl_arg.`alist`.load().address))
                           ^

Expression [7]:29:1:     no viable expansions found
def __mojo_repl_expr_impl__(inout __mojo_repl_arg: __mojo_repl_context__, inout `secs`: __mlir_type.`!kgen.declref<@"$python"::@"$object"::@PythonObject>`, inout `python_numpy_dist`: __mlir_type.`!kgen.declref<@"$python"::@"$object"::@PythonObject>`, inout `___lldb_expr_failed`: __mlir_type.`!kgen.declref<@"$builtin"::@"$bool"::@Bool>`, inout `python_naive_dist`: __mlir_type.`!kgen.declref<@"$python"::@"$object"::@PythonObject>`, inout `time`: __mlir_type.`!kgen.declref<@"$python"::@"$object"::@PythonObject>`, inout `print_formatter`: __mlir_type.`!kgen.declref<@"$python"::@"$object"::@PythonObject>`, inout `np`: __mlir_type.`!kgen.declref<@"$python"::@"$object"::@PythonObject>`, inout `n`: __mlir_type.`!kgen.declref<@"$python"::@"$object"::@PythonObject>`, inout `bnp`: __mlir_type.`!kgen.declref<@"$python"::@"$object"::@PythonObject>`, inout `blist`: __mlir_type.`!kgen.declref<@"$python"::@"$object"::@PythonObject>`, inout `anp`: __mlir_type.`!kgen.declref<@"$python"::@"$object"::@PythonObject>`, inout `alist`: __mlir_type.`!kgen.declref<@"$python"::@"$object"::@PythonObject>`) -> None:
^

Expression [7]:43:26:       call expansion failed - no concrete specializations
  __mojo_repl_expr_body__()
                         ^

Expression [7]:31:3:         no viable expansions found
  def __mojo_repl_expr_body__() -> None:
  ^

Expression [7]:35:5:           could not simplify operator get_alignof(!lit.unresolved, #kgen.target<triple = "x86_64-unknown-linux-gnu", cpu = "znver1", features = "+64bit,+adx,+aes,+avx,+avx2,+bmi,+bmi2,+clflushopt,+clzero,+cmov,+crc32,+cx16,+cx8,+f16c,+fma,+fsgsbase,+fxsr,+lzcnt,+mmx,+movbe,+mwaitx,+pclmul,+popcnt,+prfchw,+rdrnd,+rdseed,+sahf,+sha,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+sse4a,+ssse3,+xsave,+xsavec,+xsaveopt,+xsaves", data_layout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128", simd_bit_width = 256>)
    var a = Tensor[DType.float64](n)
    ^

expression failed to parse (no further compiler diagnostics)

but other mojo cells work... so I'm not sure if this is a separate issue.

@ematejska ematejska added the mojo-repo Tag all issues with this label label May 6, 2024
@ematejska ematejska added the mojo Issues that are related to mojo label Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request mojo Issues that are related to mojo mojo-repo Tag all issues with this label
Projects
None yet
Development

No branches or pull requests

6 participants