我正在运行另一个用户的一些代码来构建一个卷积网络。一个早期的函数试图通过运行将训练和测试图像复制到 /dev/shm
:
import os
import time
paths = ["data/raw/images_train_rev1", "data/raw/images_test_rev1"]
for path in paths:
if os.path.exists(os.path.join("/dev/shm",os.path.basename(path))):
print "%s exists in /dev/shm, skipping." % path
continue
print "Copying %s to /dev/shm..." % path
start_time = time.time()
os.system("cp -R %s /dev/shm/" % path)
print " took %.2f seconds." % (time.time() - start_time)
我收到错误:
cp: /dev/shm: Permission denied
cp: data/raw/images_test_rev1: unable to copy extended attributes to
/dev/shm: No such file or directory
有没有可以在我的 Mac 上使用的 /dev/shm
的替代品?
我已经使用这些信息在 OSX 中创建了一个 ramdisk:
http://osxdaily.com/2007/03/23/create-a-ram-disk-in-mac-os-x/
然后: ls -lah/dev/rdisk1 crw-------- 1 xxxx staff 1, 4 27 May 16:26/dev/rdisk1
但是,当我尝试写入时出现错误:
/rdisk1 is not a directory
took 0.78 seconds.
Copying data/raw/images_test_rev1 to /dev/rdisk1...
cp: /dev/rdisk1 is not a directory
took 0.02 seconds.
希望能帮到你。谢谢。
最佳答案
您可以使用此实用程序 https://gist.github.com/koshigoe/822455
cd /tmp
git clone https://gist.github.com/822455.git
cd 822455
chmod +x *
sudo ./mount-ram.sh /dev/shm 1024
sudo chmod 777 /dev/shm
它将在RAM中创建一个1G的可写/dev/shm
文件夹
关于python - 在 Mac 上将文件复制到 RAM (Python),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30474044/