nvidia optimus 기술은 Laptop에서 내장 그래픽(주로 intel계열)과 외장 gpu를 선택적으로 사용하여 그래픽 요구사양이 높지 않은 작업을 할때는 내장 그래픽만 사용하여 배터리 전원을 절약하게 해주는 기술이다.

그런데 이 기술이 nvidia의 고유한 기술이다 보니 윈도우 같이 최적화가 잘된 OS를 제외하고 ubuntu 등 linux에서 드라이버가 제대로 선택되지 않아 그래픽 가속이 안되거나 화면 렌더링이 깨지는 현상이 발생한다. 주요 현상은 다음과 같다.

 - 터미널에 글자를 입력할때 딜레이가 생기는 경우

 - GUI가 깨지는 현상

 - GUI가 늦게 그려지는 현상

 

특히 경량화된 노트북에서 많이 발생하는데 이 문제가 발생하면 원인을 파악하기도 어렵고 드라이버를 아무리 재설치해봐도 딱히 개선되거나 하지 않는다. 

여기서는 Lenovo Yoga slim 7 에 intel i5 cpu가 탑재되고 nvidia MX350 그래픽이 설치된 노트북에 우분투 20.04가 설치된 환경으로 작성하였다.

 

먼저 ubuntu 20.04를 iso 이미지를 통해 설치를 진행한다.

처음에는 당연히 내장 그래픽만 사용하므로 큰 문제가 없다. 

하지만 nvidia 그래픽 드라이버를 설치하면서 문제가 발생하기 시작한다.

nvidia 그래픽 카드는 apt 방식으로 설치하기 위해 다음과 같이 진행한다.

ppa 등록하기

$ sudo add-apt-repository ppa:graphics-drivers/ppa

nvidia driver 470 설치

$ sudo apt install nvidia-driver-470

 

또는 시작 버튼 -> Software & Update 실행 

Additional Drivers 탭에서 nvidia-driver-470 을 선택

드라이버 설치후 재부팅 진행

터미널에 nvidia-smi를 입력하면 다음과 같은 화면이 나타난다.

하지만 이 노트북의 경우 GPU가 3D 가속만을 담당하고 VGA 가속을 지원하지 않기때문에 아래와 같이 입력하면 VGA는 여전히 Intel 그래픽이 담당하고 있다.

$ lspci | egrep -i "vga|display|3d"
00:02.0 VGA compatible controller: Intel Corporation Iris Plus Graphics G1 (Ice Lake) (rev 07)
30:00.0 3D controller: NVIDIA Corporation GP107M [GeForce MX350] (rev a1)

 

이러한 경우 우분투의 GUI환경을 담당하는 xorg 서버가 VGA 가속도 GPU가 담당하는 것으로 착각하고 intel 내장 그래픽의 그래픽 가속이 적용되지 않고 gpu에 맡겨버리는 현상이 발생하여 그래픽 관련한 여러가지 딜레이와, 답답한 문제들이 발생한다.

 

이 문제의 원인은 우분투의 PSR이라는 기능 때문이다.

다음 버그 리포트에 해당 문제에 대한 논의가 있고 해결책으로 PSR을 끄는 방법을 제시하고 있다.

https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1937072 

 

Bug #1937072 “[Lenovo Yoga Slim 7 14IIL05] PSR causes incomplete...” : Bugs : linux package : Ubuntu

In every 6/10 boot my ubuntu failed to start stuck on blank screen. Sometime touchpad stop working and unable to change my brightness after installation at first all feature are perfectly fine except screen glitch.Screen performance is laggy. ProblemType:

bugs.launchpad.net

해결 방법은 /etc/default/grub 을 에디터로 열고 GRUB_CMDLINE_LINUX_DEFAULT 항목을 찾아서 "i915.enable_psr=0" 으로 설정하는 것이다.

GRUB_CMDLINE_LINUX_DEFAULT="i915.enable_psr=0"

만약 기존에 GRUB_CMDLINE_LINUX_DEFAULT 항목이 있으면 앞에 # 를 넣어서 comment 처리한다.

이렇게 저장한 다음 다음을 수행하고 재부팅한다.

$ sudo update-grub
$ sudo reboot

재부팅 후 PSR이 disable되었는지 확인하기 위해 다음을 입력한다.

$ sudo cat /sys/module/i915/parameters/enable_psr

이 값이 "0" 이 되어야한다.

만약 이 값이 "1" 또는 "-1"이면 적용되지 않은것이다.

 

해결 방법은 부팅 중 xorg의 설정을 담당하는 /etc/X11/ 의 xorg.conf 파일을 생성하여 VGA 가속을 내장 그래픽이 수행하도록 명시하는 방법인데 /etc/X11/xorg.conf 파일을 만들고 그 안에 다음과 같은 내용을 추가한다.

Section "ServerLayout"
    Identifier "layout"
    Screen 0 "intel"
    Screen 1 "nvidia"
EndSection

Section "Device"
    Identifier "intel"
    Driver "intel"
    BusID "PCI:0@0:2:0"
    Option "AccelMethod" "sna"
    Option      "DRI"   "1"
EndSection

Section "Screen"
    Identifier "intel"
    Device "intel"
EndSection

Section "Device"
    Identifier "nvidia"
    Driver "nvidia"
    BusID "PCI:1@0:0:0"
    Option "ConstrainCursor" "off"
EndSection

Section "Screen"
    Identifier "nvidia"
    Device "nvidia"
    Option "AllowEmptyInitialConfiguration" "on"
    Option "IgnoreDisplayDevices" "CRT"
EndSection

이렇게 저장하고 재부팅하면 정상적으로 그래픽 가속이 내장 그래픽에 의해 수행됨을 확인할 수 있다.

만약 이렇게 했는데 안된다면 다음을 입력하여 xorg-intel 패키지를 설치한다.

$ sudo apt-get install xserver-xorg-video-intel

 

다음은 유투브에 2013년에 올라온 아시아나 214편 항공 관제 (ATC) 교신 내용 녹음 파일의 댓글에 남겨진 글을 번역한 것입니다. 대체 이렇게 맑은 날씨에 왜 이런 사고가 발생하게 되었는지를 기술적인 부분 보다는 조종 문화, 비행기를 조종하는 사람에 대한 관점으로 바라본 글이 인상적이어서 따로 번역하였습니다. 일부 오역이나 저의 생각이 혼재되었을 수 있음을 감안하여주시면 고맙겠습니다. 

 

해당 댓글은 8개월 전에 작성되었습니다. 관련 링크는 여기로 https://youtu.be/Q5oCnZbNPtY

 

Everett Jay

 

아시아나 항공에서 11년간 비행했던 사람으로서 아시아나 항공에서는 장담컨데 거의 모든 조종사들이 육안 접근을 훈련하지 않습니다. 날씨가 아무리 맑더라도 착륙 내내 고개를 푹 숙인채 글라이드슬롭(*경사 지시계)과 로컬라이저(**수평 지시계)로부터 벗어나지 않기 위해 계기를 쳐다볼 뿐입니다. 자동조종장치를 켜거나 최소한 자동 출력 장치를 켠채 말이죠.

*활주로 접지 지점으로부터 3도 경사로 부터 벗어난 정도를 표시함

**활주로 접지 지점에서 활주로 진행 방향(0도~359도)으로부터 벗어난 각도를 표시

 

 왜 이렇게 하냐고요? 왜냐하면 모든 아시아나 항공의 경영진들은 항공사의 엄격하고 때로는 어리석기까지 한 규칙에서 벗어난 조종사를 벌주기 위해 QAR(Quick Access Recorder) 데이터를 사용하기 때문입니다. 한가지 예를들면 택싱하는 도중 규정 속도를 10노트 이상 초과하거나 50도 이상의 회전을 하게 되면 QAR에 붉은 글자가 표시되는 겁니다. 비록 정확한 접지 위치에 내려더라도 착륙 도중 글라이드 슬롭 이탈이 발생하거나 활주 거리 초과가 발생하는 경우도 마찬가지입니다. 심지어 조종사들을 특정한 매개변수 박스 안에 집어 넣고 그 안에서 조작하게끔 하는 50개가 넘는 엄격한 운항 지침이 존재합니다. 바로 이 운항 지침의 테두리 안에서 비행을 하다보면 조종간과 러더 기술이 부족해지기 마련입니다. 그리고 그들은 이 데이터를 기준으로 조종사의 실력을 판가름 하여 (F1 에서 F10까지) 기장으로의 승진 여부를 결정합니다. 기장이 되더라도 QAR 변수들은 여전히 유효합니다.

 

경영자들 혹은 리더 들은 이 데이터를 기반으로 개별 조종사들을 벌주고 심지어 봉급에서 수백만원씩 삭감하기도 합니다. 심지어 누가 좋은 조종사이고 기장이 될 자격이 있는지를 판별합니다. 아시아에서는 돈이 모든걸 결정합니다. 기장이 되고 그만큼의 봉급을 받는다는 것은 리더들에게 가능한 적은 숫자의 붉은 QAR 데이터를 보여주는 것입니다.

 

이제 여러분은 대체 이게 777 항공기가 맑은 날에 바다 장벽으로 처박게 된거랑 무슨 상관이냐고 물을겁니다. 바로 이날 글라이드슬롭과 로컬라이저는 운용이 중단되었습니다. 조종사들은 이것이 NOTAM에 자동 불가라고 씌어 있었음에도 불구하고 이를 예상하지 못했습니다. 이제 그들은 이 여객기를 어떠한 계기의 도움 없이 문자 그대로 손으로 조종해야했는데 사실 이것은 아시아나 항공에서는 절대 하지 말아야할 일입니다. 그들은 어떠한 접근에서도 절대로(!) 자동 출력 조절장치를 끄지 않습니다. 이 조종사들은 무슨일이 벌어지고 있는가(로컬라이저, 글라이드 슬롭 out)에 대해 혼동하고 있었고, (아무도 훈련시키지 않기 때문에)육안으로 하는 수동 조종 기술이 부족한데다가 QAR 데이터가 붉은 글자를 표시할까봐 전전긍긍하고 있었습니다.

 아마도 모든 외국인 조종사들은 이러한 사고가 발생한 원인중 하나로 이렇게 부족한 훈련 문화와 새로운 항공기 타입에 새로운 조종사가 엮인거다 라고 생각할 것입니다. 아마도 저는 이 주제를 가지고 한권의 책을 쓸수도 있습니다. 다만 여기서는 아시아 지역에서 근무하는 외국인 조종사들의 대체적인 시각을 공유하고자 합니다.

 

전투기 조종사 출신을 포함하여 대부분의 아시아 지역 조종사들은 미국/유럽 그리고 나머지 99%의 나라들의 조종사들이 항공사 조종사들이 되기까지 거치는 과정들을 거치지 않습니다. 그들은 세스나 172에서 곧바로 제트 항공기로 직행합니다. 그들은 화물기, 전세항공기, 교관 비행등을 통해 경함할 수 있는 강한 측풍 착륙이나 온갖 변수들에 대해 준비되지 않은채로 기장 훈련을 시작하게 됩니다. 그들은 국제적인 비행 규칙에 대한 조언, 기초적인 판단 능력, 문제 해결 능력, 기본 비행 기술등이 부족한 상태로 QAR의 붉은 데이터에 대한 공포심에 사로잡혀 비행을 합니다.

 이것은 그들이 어리석다는 의미가 아닙니다. 이것은 교과서에서 가르칠 수 없는 항공과 문화에 대한 이야기입니다. 언젠가는 이것이 변화될 수 있기를 진심으로 기원합니다.

 

원문은 다음과 같습니다.

As someone who has flown for an Asian Airline for 11 years, I can tell you that Asian Airlines (almost all of them), do not train visual approaches. Even when the weather is clear, the have their heads down and are watching the Glideslope and Localizer needles to make sure they are centered all the way to landing. All with the autopilot on or at the very least, the auto thrust. So, why do they do this? It’s because ALL Asian airlines use QAR Data to punish pilots that deviate from the Airlines strict and idiotic permitters that they set. Let me give you an example.... Taxiing more than 10 knots and making a turn of more than 50 deg. Results in a hard (RED) QAR. Another one is G/S deviation on landing as well as a Long Landing.... (even though you touch down in the touchdown zone). And there are 50 more strict guidelines the airlines put in place in order to keep their pilots in a Box of Parameters to work from. What they lack in stick and rudder skills are supplemented by this box of operating guidelines. They then use this data to access the quality of that pilot for upgrades in First officers as they move from F1-F10 (F10 being almost a captain). Once your a Captain, those same QAR Parameters still apply. The “leaders” then use this data on each pilot (yes names are attached to this dats....), to punish the pilots with deductions from their paychecks.... Sometimes in the thousands of dollars and additionally use this data also to decide who is a good pilot and should be moved to a Captain position. In Asia, money rules! Being a Captain and making that money drives all of them to show the leaders how few Red QAR’s they have. So you will now ask, how does this make a 777 fly into a sea wall on a clear day? On this day, the G/S and LOC guidance was out of service. The pilots didn’t expect this even though it was NOTAM(ed) out. Not to mention it was written in English. Now they were forced to hand fly this jet (laterally and Vertically)without guidance to the runway and that is something Asian Airlines DO NOT DO. They do not disconnect the Autothrottles on ANY approaches...ever! These pilots were confused on what was going on (no LOC or G/S guidance), lacked basic hand flying skills based on line of sight (because they don’t train this) and were VERRY worried about the QAR data flagging them in all their confusion. Couple this with poor training culture, new pilots on new aircraft Type and you will just barely.get a glimpse of what every expat pilot in Asia sees as a Major setup for accidents just like this. I could actually write an entire book about this subject but just thought I’d share just a little insight into Something every expat pilot in Asia already knows. Fighter Jet pilots or not, Asian airlines do not work their way up to being an airline pilot like in the USA/Europe and the other 99% of the world. They go from a Cessna 172 straight to a jet. They don’t fly cargo, charter work, flight instruct or do anything that prepares them for even a strong crosswind landing until they start Captain training. They lack experience, proper mentorship both in International flight rules and the basics in decision making (thinking for yourself), problem solving, basic skills and live in fear of the RED QAR. It’s NOT that they are stupid... they are far from that. It’s an aviation and culture issue that can not be taught in any textbook. This leaves them behind the rest of the world and I sincerely hope some day this changes.

Raspbian buster 설치하기

다음 페이지를 방문하여 Raspbian Buster with desktop 를 다운로드 한다.

https://www.raspberrypi.org/downloads/raspbian/

 

Download Raspbian for Raspberry Pi

Raspbian is the Foundation's official supported operating system. You can install it with NOOBS or download the image below.

www.raspberrypi.org

ROS-melodic 설치하기

자세한 설치 방법은 https://blog.seeedstudio.com/blog/2019/08/01/installing-ros-melodic-on-raspberry-pi-4-and-rplidar-a1m8/comment-page-1/#comment-230658 페이지를 참조합니다.

1) 의존성 패키지 다운로드하고 설치하기

repository 설정하고 필요한 의존성 패키지를 설치합니다.

$ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'

$ sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

$ sudo apt-get update

$ sudo apt-get install -y python-rosdep python-rosinstall-generator python-wstool python-rosinstall build-essential  cmake

 

rosdep 초기화하고 업데이트

sudo rosdep init

rosdep update

ROS 설치를 위한 workspace 만들고 이동

mkdir ~/ros_catkin_ws

cd ~/ros_catkin_ws

ROS Desktop 설치하기

$ rosinstall_generator desktop --rosdistro melodic --deps --wet-only --tar > melodic-desktop-wet.rosinstall

$ wstool init -j8 src melodic-desktop-wet.rosinstall

2) 이슈 해결

collada_urdf 의존성 문제 해결을 위해 별도로 호환되는 버전의 Assimp를 빌드하고 설치합니다.

먼저 ros_catkin_ws 폴더 아래에 external_src 폴더를 만들고 assimp-3.1.1 소스를 다운로드하고 압축을 해재합니다.

$ mkdir -p ~/ros_catkin_ws/external_src

$ cd ~/ros_catkin_ws/external_src

$ wget    http://sourceforge.net/projects/assimp/files/assimp-3.1/assimp-3.1.1_no_test_models.zip/download -O assimp-3.1.1_no_test_models.zip

$ unzip assimp-3.1.1_no_test_models.zip

이제 압축 해제한 assimp 폴더로 이동하여 다음 순서대로 컴파일 및 설치를 진행합니다.

cd assimp-3.1.1

cmake .

make

sudo make install

설치가 완료되면 rviz를 위한 OGRE를 설치합니다.

sudo apt-get install  libogre-1.9-dev

rosdep 도구를 통한 의존성 패키지 설치하기

아래 명령어를 통해 설치 의존성 패키지들을 다운로드하고 설치합니다.

$ rosdep install --from-paths src --ignore-src --rosdistro melodic -y

이때 결과가 다음과 같이 모든 의존성 패키지들의 설치가 완료되었다는 메세지가 나와야합니다.

#All required rosdeps installed successfully

 

3) Navigation 관련 패키지 추가하기

ROS-Desktop 버전에 빠진 패키지나 항목들을 추가하기 위해 ros_catkin_ws/src 에 다음을 수행합니다.

Joystick 관련

$ sudo apt-get install -y jstest-gtk joystick xboxdrv libusb-dev libbluetooth-dev

$ sudo apt install python-defusedxml libpoco-dev libtinyxml2-dev libspnav-dev libx11-dev libcwiid-dev liblz4-dev

$ sudo apt-get install libsdl-image1.2-dev

$ sudo apt-get install libsdl-dev

cd to /src

 

누락된 패키지들을 새로 다운받기 위해 해당 폴더를 삭제

$ rm -rf navigation

$ rm -rf slam_gmapping/

$ rm -rf geometry2

$ rm -rf navigation_msgs/

git repository로부터 패키지 소스를 다운로드

$ git clone https://github.com/ros-drivers/joystick_drivers.git

$ git clone https://github.com/ros-planning/navigation.git

$ git clone https://github.com/ros-perception/slam_gmapping.git

$ git clone https://github.com/ros/geometry2.git

$ git clone https://github.com/ros-planning/navigation_msgs.git

4) ROS Build하고 설치하기

설치를 진행하기에 앞서 라즈베리파이의 기본 스왑 사이즈를 100MB에서 2048로 변경해야합니다.

SWAP Size 변경하기

sudo dphys-swapfile swapoff

/etc/dphys-swapfile 파일을 편집기에서 열고 다음과 같이 수정 (기본 설정은 100MB임)
CONF_SWAPSIZE=2048
그리고 나서 다음을 입력하여 스왑 ON

sudo dphys-swapfile swapon


Source에서 Build하기

아래 명령어를 입력하여 소스로부터 빌드하고 /opt/ros/melodic에 설치합니다.

sudo ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/melodic -j2

bashrc에 ROS 경로 추가하기

echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc

 

Workspace 만들기


$ mkdir -p ~/catkin_ws/src
$ cd ~/catkin_ws/
$ catkin_make
$ catkin_make -DPYTHON_EXECUTABLE=/usr/bin/python3 -DPYTHON_INCLUDE_DIR=/usr/include/python3.7m -DPYTHON_LIBRARY=/usr/lib/libpython3.7m.so

.bashrc에 catkin_ws 빌드 경로 추가하기

$ echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc

+ Recent posts