Copying files to RAM on Mac (Python)

I am running some code from another user which builds a convnet. An early function attempts to copy the train and test images to /dev/shm by running:

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

    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)

I am getting the errors:

cp: /dev/shm: Permission denied
cp: data/raw/images_test_rev1: unable to copy extended attributes to 
/dev/shm: No such file or directory

Is there an alternative to /dev/shm that I can use on my Mac?

I have created a ramdisk in OSX using this information:

ls -lah /dev/rdisk1
crw——- 1 xxxx staff 1, 4 27 May 16:26 /dev/rdisk1

However, when I try to write to it I get the error:

/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.

Hope you can help. Thanks.

Source: unix

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.