1

我正在运行来自另一个构建 convnet 的用户的一些代码。早期的函数尝试/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

/dev/shm有没有可以在我的 Mac 上使用的替代方案?


我使用以下信息在 OSX 中创建了一个 ramdisk:

http://osxdaily.com/2007/03/23/create-a-ram-disk-in-mac-os-x/

然后: ls -lah /dev/rdisk1 crw------- 1 xxxx 员工 1, 4 5 月 27 日 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.

希望你能帮忙。谢谢。

4

1 回答 1

2

您可以使用此实用程序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

它将/dev/shm在RAM中创建一个1G的可写文件夹

于 2015-05-27T06:10:38.157 回答