简体   繁体   English

scikit-learn joblib:导入权限错误,以串行模式运行

[英]scikit-learn joblib: Permission error importing, run in Serial mode

The following permission error occurs when I try importing joblib from script or python -c 'import joblib' : 当我尝试从脚本或python -c 'import joblib'导入joblib时发生以下权限错误:

/usr/local/lib/python2.7/dist-packages/joblib//joblib_multiprocessing_helpers.py:29: UserWarning: [Errno 13] Permission denied.  joblib will operate in serial mode
      warnings.warn('%s.  joblib will operate in serial mode' % (e,))
  • joblib is installed and forcefully reinstalled via pip 通过pip安装并强制重新安装joblib
  • importing works as superuser 导入以超级用户身份运行
  • I set full permissions on the joblib folder chmod -R 777 /usr/local/lib/python2.7/dist-packages/joblib ; 我在joblib文件夹chmod -R 777 /usr/local/lib/python2.7/dist-packages/joblib上设置了完全权限; to no avail: the permission error remains 无济于事:许可错误仍然存​​在

So even though every user and group has full rwx permissions on the joblib directory it gives me a permission error. 因此,即使每个用户和组在joblib目录上都具有完整的rwx权限,它也会给我一个权限错误。 How do I figure out on which directory joblib does the write permission check when importing? 如何确定joblib在导入时执行写入权限检查的目录? Why does it even do the check before I specified a write operation? 为什么在我指定写操作之前它甚至会进行检查?

Found it by looking a in the joblib source code: 通过查看joblib源代码找到它:

The problem was that semaphoring was not enabled on my system: Joblib checks for multiprocessing.Semaphore() and it turns out that only root had read/write permission on shared memory in /dev/shm. 问题是我的系统上没有启用信号量:Joblib检查多处理.Semaphore(),结果证明只有root对/ dev / shm中的共享内存有读/写权限。 Fixed it as per this answer by permanently setting the correct permissions (even after a reboot) by adding the following to your /etc/fstab: 通过在/ etc / fstab中添加以下内容,永久设置正确的权限(即使重启后),修复了此问题

none /dev/shm tmpfs rw,nosuid,nodev,noexec 0 0 and then remount mount /dev/shm -o remount none /dev/shm tmpfs rw,nosuid,nodev,noexec 0 0然后重新挂载mount /dev/shm -o remount

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM