2015-05-27 49 views
1

我正在運行構建一個convnet的另一個用戶的一些代碼。早期的功能試圖通過運行列車和測試圖像/dev/shm複製:將文件複製到Mac上的RAM(Python)

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上使用?

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

然後::


我在OSX使用該信息來創建虛擬盤 LS -lah的/ dev/rdisk1 CRW ------- 1 XXXX 1人員,4月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. 

希望你能幫上忙。謝謝。

+0

任何地方被安裝爲'tmpfs' –

+0

旁註創建1G的可寫/dev/shm文件夾:'使用os.system()'已經被'subprocess'模塊的函數取代:https://docs.python.org/2/library/subprocess.html。 – EOL

回答

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