DEV Community

Cover image for Python 3.13 GPU on Jetson Nano with Headless Mac M3
제민욱
제민욱

Posted on • Edited on

Python 3.13 GPU on Jetson Nano with Headless Mac M3

I'll set up my Jetson Nano as a headless device, connecting it to my MacBook via USB-C to Ethernet. The Mac will be on Wi-Fi, sharing its internet with Jetson while I access it over SSH, ensuring Jetson operates without Wi-Fi.

1. Product

Image description

  • USB 3.1 c-type to RJ45

Image description

  • M3 Macbook

2. Setup

1. Physical Connection

  • Connect the Mac and Jetson using a USB-C to LAN adapter and an Ethernet cable.

Image description

2. Mac Configuration

  • System Preferences > Network > Ethernet(LAN):
    • Select "Configure Using DHCP" to automatically assign an IP (typically 192.168.2.1).
  • System Preferences > Sharing:
    • Enable "Internet Sharing".
    • Share from: Wi-Fi, To computers using: Ethernet(LAN).

3. Jetson Configuration

  • Install and enable SSH server:
$ sudo apt update
$ sudo apt install openssh-server
$ sudo systemctl enable ssh
$ sudo systemctl start ssh
Enter fullscreen mode Exit fullscreen mode
  • Disable Wi-Fi (use Mac connection only):
$ nmcli radio wifi off
Enter fullscreen mode Exit fullscreen mode
  • Set a static IP for the Ethernet interface:
$ sudo nmcli connection modify "Wired connection 1" ipv4.method manual ipv4.addresses "192168.2.2/24" ipv4.gateway "192.168.2.1" ipv4.dns "8.8.8.8"
$ sudo nmcli connection up "Wired connection 1"
Enter fullscreen mode Exit fullscreen mode

4. Verify Connection

  • SSH into Jetson from Mac:
$ ssh jetson@192.168.2.2
Enter fullscreen mode Exit fullscreen mode
  • Check internet connectivity from Jetson:
$ ping google.com
Enter fullscreen mode Exit fullscreen mode

3. Upgrade Ubuntu version

20.04 -> 22

$ sudo apt update && sudo apt upgrade -y
$ sudo do-release-upgrade
Checking for a new Ubuntu release
In /etc/update-manager/release-upgrades Prompt
is set to never so upgrading is not possible.

$ sudo vim /etc/update-manager/release-upgrades
# Change Prompt=never to Prompt=lts, save, and exit
$ sudo reboot now
$ sudo do-release-upgrade

Enter fullscreen mode Exit fullscreen mode

Problem occured

1. Jetson의 현재 IP 주소 확인

  • Jetson에 모니터와 키보드 연결 가능 시:

    • Jetson에 직접 접근하여 터미널에서 다음 명령어를 실행해 IP 주소를 확인합니다:
    ip addr show
    

    또는

    nmcli connection show
    
    • Ethernet 인터페이스(예: eth0 또는 enx*)에 할당된 IP 주소를 확인하세요. 예를 들어, 192.168.2.2가 아닌 다른 주소(예: 192.168.2.xxx)가 보인다면 그 IP로 SSH 접속을 시도해 보세요:
    ssh jetson@새로운_IP
    
  • 모니터 연결 불가능 시:

    • MacBook에서 네트워크 내 장치를 스캔하여 Jetson의 새 IP를 찾습니다:
    arp -a
    
    • Jetson의 MAC 주소(하드웨어 주소)를 알고 있다면 해당 항목을 찾으세요.
    • 잘 모를 경우, 브로드캐스트 핑으로 장치를 탐색한 뒤 다시 확인:
      ping 192.168.2.255
      arp -a
    

2. 정적 IP 재설정

  • IP가 변경되었다면 Jetson에 접속하여 정적 IP를 다시 설정합니다:
  sudo nmcli connection modify "Wired connection 1" ipv4.method manual ipv4.addresses "192.168.2.2/24" ipv4.gateway "192.168.2.1" ipv4.dns "8.8.8.8"
  sudo nmcli connection up "Wired connection 1"
Enter fullscreen mode Exit fullscreen mode
  • 인터페이스 이름이 Wired connection 1이 아닌 경우, nmcli connection show로 정확한 이름을 확인한 뒤 명령어에 반영하세요.

3. SSH 서비스 상태 확인

  • Jetson에 접근 가능하면 SSH 서비스가 실행 중인지 확인합니다:
  sudo systemctl status ssh
Enter fullscreen mode Exit fullscreen mode
  • 실행 중이 아니라면 시작하고, 부팅 시 자동 실행되도록 설정합니다:
  sudo systemctl start ssh
  sudo systemctl enable ssh
Enter fullscreen mode Exit fullscreen mode

4. MacBook 설정 점검

  • 인터넷 공유 활성화 여부 확인:
    • MacBook의 System Preferences > Sharing에서 "Internet Sharing"이 켜져 있고, "Wi-Fi"에서 "Ethernet(LAN)"으로 공유 중인지 확인하세요.
  • Ethernet IP 확인:
    • System Preferences > Network > Ethernet(LAN)에서 MacBook의 IP가 192.168.2.1인지 확인합니다. 그렇지 않다면 "Configure Using DHCP"로 설정 후 재부팅해 보세요.

5. 연결 테스트

  • 모든 설정을 마친 후 MacBook에서 다시 SSH 접속을 시도합니다:
  ssh jetson@192.168.2.2
Enter fullscreen mode Exit fullscreen mode
  • Jetson에서 인터넷 연결도 확인합니다:
  ping google.com
Enter fullscreen mode Exit fullscreen mode

추가 팁: 향후 문제 예방

  • 네트워크 설정 백업: 업그레이드 전 /etc/NetworkManager/system-connections/ 디렉토리를 백업하세요.
  • 업그레이드 로그 확인: /var/log/dist-upgrade/에서 네트워크 관련 오류를 점검하세요.
  • 인터페이스 이름 고정: udev 규칙으로 네트워크 인터페이스 이름을 고정하여 이름 변경을 방지할 수 있습니다.

결론

가장 의심되는 정황은 Ubuntu 업그레이드로 인해 Jetson의 IP 주소가 변경되거나 네트워크 설정이 초기화된 것입니다. 위 단계를 통해 새 IP를 찾거나 정적 IP를 재설정하고, SSH 서비스와 MacBook 설정을 점검하면 문제를 해결할 수 있을 것입니다.

4. Cuda12 & Pytorch2.*

$ sudo apt install -y python3.12
$ python3 --version

# cuda
$ sudo apt install -y ubuntu-drivers-common
$ sudo ubuntu-drivers autoinstall
$ sudo apt-get install -y cuda-toolkit-12-6

$ echo 'export PATH=/usr/local/cuda-12.6/bin:$PATH' >> ~/.bashrc
$ echo 'export LD_LIBRARY_PATH=/usr/local/cuda-12.6/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc
$ source ~/.bashrc

$ nvidia-smi # check

# pytorch 2.x
$ python3.12 -m venv .venv
$ source .venv/bin/activate
$ pip install torch --index-url https://download.pytorch.org/whl/cu126
$ pip install torchvision torchaudio
$ python3 -c "import torch; print('PyTorch version:', torch.__version__); print('Device:', torch.device('cuda' if torch.has_cuda else 'cpu'))"
Enter fullscreen mode Exit fullscreen mode

Top comments (0)