DeepSpeed icon indicating copy to clipboard operation
DeepSpeed copied to clipboard

[BUG] M1 Mac has an issue with `hostname -I` not being a valid command

Open AbhinavMir opened this issue 1 year ago • 9 comments

Not a particular issue I was facing, but a very offline friend who was using deepspeed initializes got an error where HostName -I isn't available on the M1 chip or OSX in general.

A workaround I can think of is using ifconfig | grep 'inet ' | awk '{print $2}' | paste -sd ' ' instead of hostname -I - and this code fails in ./deepspeed/launcher/runner.py: ssh_check_cmd += f" {first_host} hostname -I" so probably a check for OS type using uname and then running a specific bit of code. Currently I just added a new binary to replace hostname that runs the original hostname but also parses -I to run ifconfig but it probably isn't the best idea.

I am not an AI developer but just my 2 cents!

AbhinavMir avatar May 31 '24 20:05 AbhinavMir

Hi @AbhinavMir - can you share the specific error? I know others have been able to run on M1 Macs in the past, so is it possible that the inetutils package wasn't installed which contains hostname?

loadams avatar May 31 '24 22:05 loadams

Hi Logan, I'll talk to the friend really quick and get back to you, but iirc hostname was available, but not the -I flag.

AbhinavMir avatar May 31 '24 22:05 AbhinavMir

Hi @AbhinavMir - closing this PR as stale for now, if you're able to get a little more info, please comment and we can investigate and re-open.

loadams avatar Jun 26 '24 17:06 loadams

Hello. I got the same error on Apple M3, MacOS Solomona 14.5 (23F79)

[2024-07-01 11:07:31,491] [INFO] [logging.py:96:log_dist] [Rank -1] DeepSpeed info: version=0.14.4, git-hash=unknown, git-branch=unknown
[2024-07-01 11:07:31,491] [INFO] [comm.py:637:init_distributed] cdb=None
[2024-07-01 11:07:31,492] [INFO] [comm.py:652:init_distributed] Not using the DeepSpeed or dist launchers, attempting to detect MPI environment...
[...70358] shmem: mmap: an error occurred while determining whether or not /var/folders/75/... could be created.
hostname: illegal option -- I
usage: hostname [-f] [-s | -d] [name-of-host]
Traceback (most recent call last):
  File "/Users/.../class.py", line 139, in <module>
    model_engine, optimizer,__, __ = deepspeed.initialize(
  File "/Users/.../.venv/lib/python3.9/site-packages/deepspeed/__init__.py", line 143, in initialize
    dist.init_distributed(dist_backend=dist_backend,
  File "/Users/.../.venv/lib/python3.9/site-packages/deepspeed/comm/comm.py", line 658, in init_distributed
    mpi_discovery(distributed_port=distributed_port, verbose=verbose)
  File "/Users/.../.venv/lib/python3.9/site-packages/deepspeed/comm/comm.py", line 686, in mpi_discovery
    result = subprocess.check_output(hostname_cmd, shell=True)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/subprocess.py", line 424, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['hostname -I']' returned non-zero exit status 1.

So when I run hostname -I in the terminal, I get the same error. Moreover inetutils 2.5 is already installed.

RuslanProgrammer avatar Jul 01 '24 08:07 RuslanProgrammer

Hi @RuslanProgrammer - can you please share the output of running just hostname -I in the terminal?

loadams avatar Jul 01 '24 16:07 loadams

$ hostname -I
hostname: illegal option -- I
usage: hostname [-f] [-s | -d] [name-of-host]

RuslanProgrammer avatar Jul 01 '24 16:07 RuslanProgrammer

Thanks @RuslanProgrammer and @AbhinavMir - we've confirmed on an Intel Mac that the -I option is also not available there, so this appears to be an issue with OSX rather than the M series Macs.

We will need to find either another way to list the IPs on Macs, I'll have to look into this.

loadams avatar Jul 01 '24 17:07 loadams

It does not work for me on Arch Linux with GNU inetutils, where hostname -i prints 127.0.0.1.

$ hostname -I
hostname: invalid option -- 'I'
Try 'hostname --help' or 'hostname --usage' for more information.
$ hostname --help
Usage: hostname [OPTION...] [NAME]
Show or set the system's host name.

  -a, --aliases              alias names
  -d, --domain               DNS domain name
  -f, --fqdn, --long         DNS host name or FQDN
  -F, --file=FILE            set host name or NIS domain name from FILE
  -i, --ip-addresses         addresses for the host name
  -s, --short                short host name
  -y, --yp, --nis            NIS/YP domain name
  -?, --help                 give this help list
      --usage                give a short usage message
  -V, --version              print program version

Mandatory or optional arguments to long options are also mandatory or optional
for any corresponding short options.

Report bugs to <[email protected]>.

abclop99 avatar Aug 17 '24 02:08 abclop99

@abclop99 - can you share hostname -V that way we can see if a new version has removed the -I flag?

loadams avatar Aug 19 '24 16:08 loadams