My code snippet still returns the right values on my nodes after adding the “index multiplication” and your last loop:
import torch
from torch.utils.data import Dataset, DataLoader

import ctypes
import multiprocessing as mp

import numpy as np


class MyDataset(Dataset):
    def __init__(self):
        shared_array_base = mp.Array(ctypes.c_float, nb_samples*c*h*w)
        shared_array = np.ctypeslib.as_array(shared_array_base.get_obj())
        shared_array = shared_array.reshape(nb_samples, c, h, w)
        self.shared_array = torch.from_numpy(shared_array)
        self.use_cache = False

    def set_use_cache(self, use_cache):
        self.use_cache = use_cache

    def __getitem__(self, index):
        if not self.use_cache:
            print('Filling cache for index {}'.format(index))
            # Add your loading logic here
            self.shared_array[index] = torch.ones(c, h, w) * index
        x = self.shared_array[index]
        return x

    def __len__(self):
        return nb_samples


nb_samples, c, h, w = 10, 3, 24, 24

dataset = MyDataset()
loader = DataLoader(
    dataset,
    num_workers=2,
    shuffle=False
)

for epoch in range(2):
    for idx, data in enumerate(loader):
        print('Epoch {}, idx {}, data.shape {}'.format(epoch, idx, data.sum()))

    if epoch==0:
        loader.dataset.set_use_cache(True)

loader.dataset.set_use_cache(use_cache=True)

for idx, x in enumerate(loader):
        print("Read from cache Index {} = {}".format(idx, x.sum()))

Output:
Filling cache for index 0
Filling cache for index 1
Filling cache for index 2
Filling cache for index 3
Filling cache for index 4
Epoch 0, idx 0, data.shape 0.0
Epoch 0, idx 1, data.shape 1728.0
Filling cache for index 5
Epoch 0, idx 2, data.shape 3456.0
Filling cache for index 6
Epoch 0, idx 3, data.shape 5184.0
Filling cache for index 7
Epoch 0, idx 4, data.shape 6912.0
Filling cache for index 8
Epoch 0, idx 5, data.shape 8640.0
Filling cache for index 9
Epoch 0, idx 6, data.shape 10368.0
Epoch 0, idx 7, data.shape 12096.0
Epoch 0, idx 8, data.shape 13824.0
Epoch 0, idx 9, data.shape 15552.0
Epoch 1, idx 0, data.shape 0.0
Epoch 1, idx 1, data.shape 1728.0
Epoch 1, idx 2, data.shape 3456.0
Epoch 1, idx 3, data.shape 5184.0
Epoch 1, idx 4, data.shape 6912.0
Epoch 1, idx 5, data.shape 8640.0
Epoch 1, idx 6, data.shape 10368.0
Epoch 1, idx 7, data.shape 12096.0
Epoch 1, idx 8, data.shape 13824.0
Epoch 1, idx 9, data.shape 15552.0
Read from cache Index 0 = 0.0
Read from cache Index 1 = 1728.0
Read from cache Index 2 = 3456.0
Read from cache Index 3 = 5184.0
Read from cache Index 4 = 6912.0
Read from cache Index 5 = 8640.0
Read from cache Index 6 = 10368.0
Read from cache Index 7 = 12096.0
Read from cache Index 8 = 13824.0
Read from cache Index 9 = 15552.0

That being said, I’m not familiar enough with potential side effects of mp.Array or any OS-dependent issues to be of any real help. 
My best guess is that the change in dtype might create these issues (as it seems to be the one change you’ve introduced). If you are not getting the right values with this code snippet, I would guess some multiprocessing or OS - related differences.