【问题标题】:Copying files to RAM on Mac (Python)在 Mac (Python) 上将文件复制到 RAM
【发布时间】:2015-05-27 05:41:32
【问题描述】:

我正在运行另一个用户的一些代码,它构建了一个 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

我可以在我的 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 员工 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.

希望您能提供帮助。谢谢。

【问题讨论】:

标签: python linux macos unix conv-neural-network


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-01-05
    • 2014-08-08
    • 2011-08-07
    • 2013-08-27
    • 2021-12-27
    • 2013-03-08
    • 2019-09-11
    • 1970-01-01
    相关资源
    最近更新 更多