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

  • USB 3.1 c-type to RJ45

  • M3 Macbook

2. Setup

1. Physical Connection

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

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:
<span>$ </span><span>sudo </span>apt update
<span>$ </span><span>sudo </span>apt <span>install </span>openssh-server
<span>$ </span><span>sudo </span>systemctl <span>enable </span>ssh
<span>$ </span><span>sudo </span>systemctl start ssh
<span>$ </span><span>sudo </span>apt update
<span>$ </span><span>sudo </span>apt <span>install </span>openssh-server
<span>$ </span><span>sudo </span>systemctl <span>enable </span>ssh
<span>$ </span><span>sudo </span>systemctl start ssh
$ 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):
<span>$ </span>nmcli radio wifi off
<span>$ </span>nmcli radio wifi off
$ nmcli radio wifi off

Enter fullscreen mode Exit fullscreen mode

  • Set a static IP for the Ethernet interface:
<span>$ </span><span>sudo </span>nmcli connection modify <span>"Wired connection 1"</span> ipv4.method manual ipv4.addresses <span>"192168.2.2/24"</span> ipv4.gateway <span>"192.168.2.1"</span> ipv4.dns <span>"8.8.8.8"</span>
<span>$ </span><span>sudo </span>nmcli connection up <span>"Wired connection 1"</span>
<span>$ </span><span>sudo </span>nmcli connection modify <span>"Wired connection 1"</span> ipv4.method manual ipv4.addresses <span>"192168.2.2/24"</span> ipv4.gateway <span>"192.168.2.1"</span> ipv4.dns <span>"8.8.8.8"</span>
<span>$ </span><span>sudo </span>nmcli connection up <span>"Wired connection 1"</span>
$ 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:
<span>$ </span>ssh jetson@192.168.2.2
<span>$ </span>ssh jetson@192.168.2.2
$ ssh jetson@192.168.2.2

Enter fullscreen mode Exit fullscreen mode

  • Check internet connectivity from Jetson:
<span>$ </span>ping google.com
<span>$ </span>ping google.com
$ ping google.com

Enter fullscreen mode Exit fullscreen mode

3. Upgrade Ubuntu version

20.04 -> 22

<span>$ </span><span>sudo </span>apt update <span>&&</span> <span>sudo </span>apt upgrade <span>-y</span>
<span>$ </span><span>sudo </span><span>do</span><span>-release-upgrade</span>
Checking <span>for </span>a new Ubuntu release
In /etc/update-manager/release-upgrades Prompt
is <span>set </span>to never so upgrading is not possible.
<span>$ </span><span>sudo </span>vim /etc/update-manager/release-upgrades
<span># Change Prompt=never to Prompt=lts, save, and exit</span>
<span>$ </span><span>sudo </span>reboot now
<span>$ </span><span>sudo </span><span>do</span><span>-release-upgrade</span>
<span>$ </span><span>sudo </span>apt update <span>&&</span> <span>sudo </span>apt upgrade <span>-y</span>
<span>$ </span><span>sudo </span><span>do</span><span>-release-upgrade</span>
Checking <span>for </span>a new Ubuntu release
In /etc/update-manager/release-upgrades Prompt
is <span>set </span>to never so upgrading is not possible.

<span>$ </span><span>sudo </span>vim /etc/update-manager/release-upgrades
<span># Change Prompt=never to Prompt=lts, save, and exit</span>
<span>$ </span><span>sudo </span>reboot now
<span>$ </span><span>sudo </span><span>do</span><span>-release-upgrade</span>
$ 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
    ip addr show
    ip addr show

    또는

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

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

2. 정적 IP 재설정

  • IP가 변경되었다면 Jetson에 접속하여 정적 IP를 다시 설정합니다:
<span>sudo </span>nmcli connection modify <span>"Wired connection 1"</span> ipv4.method manual ipv4.addresses <span>"192.168.2.2/24"</span> ipv4.gateway <span>"192.168.2.1"</span> ipv4.dns <span>"8.8.8.8"</span>
<span>sudo </span>nmcli connection up <span>"Wired connection 1"</span>
  <span>sudo </span>nmcli connection modify <span>"Wired connection 1"</span> ipv4.method manual ipv4.addresses <span>"192.168.2.2/24"</span> ipv4.gateway <span>"192.168.2.1"</span> ipv4.dns <span>"8.8.8.8"</span>
  <span>sudo </span>nmcli connection up <span>"Wired connection 1"</span>
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 서비스가 실행 중인지 확인합니다:
<span>sudo </span>systemctl status ssh
  <span>sudo </span>systemctl status ssh
sudo systemctl status ssh

Enter fullscreen mode Exit fullscreen mode

  • 실행 중이 아니라면 시작하고, 부팅 시 자동 실행되도록 설정합니다:
<span>sudo </span>systemctl start ssh
<span>sudo </span>systemctl <span>enable </span>ssh
  <span>sudo </span>systemctl start ssh
  <span>sudo </span>systemctl <span>enable </span>ssh
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
  ssh jetson@192.168.2.2
ssh jetson@192.168.2.2

Enter fullscreen mode Exit fullscreen mode

  • Jetson에서 인터넷 연결도 확인합니다:
ping google.com
  ping google.com
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.*

<span>$ </span><span>sudo </span>apt <span>install</span> <span>-y</span> python3.12
<span>$ </span>python3 <span>--version</span>
<span># cuda</span>
<span>$ </span><span>sudo </span>apt <span>install</span> <span>-y</span> ubuntu-drivers-common
<span>$ </span><span>sudo </span>ubuntu-drivers autoinstall
<span>$ </span><span>sudo </span>apt-get <span>install</span> <span>-y</span> cuda-toolkit-12-6
<span>$ </span><span>echo</span> <span>'export PATH=/usr/local/cuda-12.6/bin:$PATH'</span> <span>>></span> ~/.bashrc
<span>$ </span><span>echo</span> <span>'export LD_LIBRARY_PATH=/usr/local/cuda-12.6/lib64:$LD_LIBRARY_PATH'</span> <span>>></span> ~/.bashrc
<span>$ </span><span>source</span> ~/.bashrc
<span>$ </span>nvidia-smi <span># check</span>
<span># pytorch 2.x</span>
<span>$ </span>python3.12 <span>-m</span> venv .venv
<span>$ </span><span>source</span> .venv/bin/activate
<span>$ </span>pip <span>install </span>torch <span>--index-url</span> https://download.pytorch.org/whl/cu126
<span>$ </span>pip <span>install </span>torchvision torchaudio
<span>$ </span>python3 <span>-c</span> <span>"import torch; print('PyTorch version:', torch.__version__); print('Device:', torch.device('cuda' if torch.has_cuda else 'cpu'))"</span>
<span>$ </span><span>sudo </span>apt <span>install</span> <span>-y</span> python3.12
<span>$ </span>python3 <span>--version</span>

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

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

<span>$ </span>nvidia-smi <span># check</span>

<span># pytorch 2.x</span>
<span>$ </span>python3.12 <span>-m</span> venv .venv
<span>$ </span><span>source</span> .venv/bin/activate
<span>$ </span>pip <span>install </span>torch <span>--index-url</span> https://download.pytorch.org/whl/cu126
<span>$ </span>pip <span>install </span>torchvision torchaudio
<span>$ </span>python3 <span>-c</span> <span>"import torch; print('PyTorch version:', torch.__version__); print('Device:', torch.device('cuda' if torch.has_cuda else 'cpu'))"</span>
$ 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

原文链接:Python 3.13 GPU on Jetson Nano with Headless Mac M3

© 版权声明
THE END
喜欢就支持一下吧
点赞6 分享
Life is never easier, we just get stronger.
生活从未变得容易,只是我们变得更加坚强
评论 抢沙发

请登录后发表评论

    暂无评论内容