Ubuntu16.04 编译错误 c++: internal compiler error: Killed (program cc1plus)

编译错误 c++: internal compiler error: Killed (program cc1plus)

错误描述

在大疆manifold-2G 上源码安装pytorch时出现编译错误
在这里插入图片描述

解决办法

ubuntu使用cmake编译时比较耗费内存,可以查看下内存使用情况

  1. 查看swap和memory的空间使用情况
$ free -h

在这里插入图片描述
可以看出没有开辟swap空间,下面尝试开辟swap空间

  1. 创建 swap file 大小为2G
$ sudo fallocate -l 2G /swapfile 
  1. 查看swapfile
$ ls -lh /swapfile
  1. 修改文件权限,只能被root访问
$ sudo chmod 600 /swapfile
$ ls -lh /swapfile
  1. 标记文件空间
sudo mkswap /swapfile

在这里插入图片描述

执行效果

继续执行源码编译程序,编译内存空间不足问题解决。
在这里插入图片描述
参考文章
https://blog.csdn.net/sinat_31220673/article/details/95351169?spm=1001.2014.3001.5502