SuooL's Blog

蛰伏于盛夏 藏华于当春

问题解决记录

系统问题

Docker

1.Ubuntu 下安装 docker 使用非 sudo 命令的问题

1
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.38/images/json: dial unix /var/run/docker.sock: connect: permission denied

解决方法:

the error message tells you that your current user can’t access the docker engine, because you’re lacking permissions to access the unix socket to communicate with the engine.
Temporary solution
Use the sudo command to execute the commands with elevated permissions every time.
Permanent (suggested) solution
Add the current user to the docker group. This can be achieved by typing

1
sudo usermod -a -G docker $USER

You have to log out and log in again for the group membership to take effect.

2.Docker 换源

新版的 Docker 使用 /etc/docker/daemon.json(Linux) 或者 %programdata%\docker\config\daemon.json(Windows) 来配置 Daemon 。

请在该配置文件中加入(没有该文件的话,请先建一个):

1
2
3
{
"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"]
}

完成上述配置后,执行如下命令即可:

1
2
sudo systemctl daemon-reload
sudo systemctl restart docker

替换及重置Homebrew默认源

替换 brew.git:

1
2
cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git

替换 homebrew-core.git:

1
2
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git

替换 Homebrew Bottles 源: 参考:替换 Homebrew Bottles 源

在中科大源失效或宕机时可以:

  1. 使用清华源设置参考
  2. 切换回官方源:

重置 brew.git:

1
2
cd "$(brew --repo)"
git remote set-url origin https://github.com/Homebrew/brew.git

重置 homebrew-core.git:

1
2
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://github.com/Homebrew/homebrew-core.git

注释掉bash配置文件里的有关Homebrew Bottles即可恢复官方源。 重启bash或让bash重读配置文件。

Xcode 高亮和提示失效

Xcode 在长时间运行之后,会出现一个问题,那就是 例如 return 不再高亮显示了。
重启Xcode 重启机器 也不能解决和个问题。
后来找了一些资料 解决了这个问题

  1. 由于 DerivedData 问题
    • 关闭项目,Xcode 设置,选择 Localtions 点击 Derived Data 的的箭头进入 DerivedData 目录
    • 直接进入 /Users/jingwenzheng/Library/Developer/Xcode/DerivedData 目录,删除这里面所有的文件
    • 重启Xcode
  2. 由于 pch 文件的问题
    • 把.pch里的内容全部注释掉,clean掉项目里的内容,把.pch里的注释去掉,编译。代码高亮,语法提示功能都回来了。

Ubuntu “sudo: unable to resolve host 主机名称”错误解决方法

解决方法:
编辑 /etc/hostssudo nano /etc/hosts
127.0.0.1 locallhost下面添加一行:127.0.0.1 你的主机名称即可

Mac OS/Linux命令查询网络端口占用情况

netstat命令

1
netstat -an | grep <port>

lsof命令
通过list open file命令可以查看到当前打开文件,在linux中所有事物都是以文件形式存在,包括网络连接及硬件设备。

1
lsof -i:80

-i参数表示网络链接,:80指明端口号,该命令会同时列出PID,方便kill

查看所有进程监听的端口

1
sudo lsof -i -P | grep -i "listen"

Mac 挂载NTFS移动硬盘进行读写操作

找到挂在节点

1
diskutil info /Volumes/YOUR_NTFS_DISK_NAME 

找到 Device Node
例如

1
Device Node:              /dev/disk1s1

推出存储介质

1
hdiutil eject /Volumes/YOUR_NTFS_DISK_NAME

结果如:"disk1" ejected.

  1. 创建一个目录,稍后将mount到这个目录
1
sudo mkdir /Volumes/MYHD
  1. 将NTFS硬盘 挂载 mount 到mac
1
sudo mount_ntfs -o rw,nobrowse /dev/disk1s1 /Volumes/MYHD/

VSCode

mac vscode Python配置
使用vs(visual studio code)写python代码遇到的import requests失败问题

TensorFlow

源码编译安装TensorFlow
TensorFlow如何充分使用所有CPU核数,提高TensorFlow的CPU使用率,以及Intel的MKL加速
Tensorflow并行计算:多核(multicore),多线程(multi-thread),图分割(Graph Partition)

DL

Jupyter

  1. Jupyter python3 notebook cannot recognize pandas
    in jupyter notebook:
    !pip install pandas
泡面一杯