Change cache path

This commit is contained in:
augustin64 2022-05-21 18:51:44 +02:00
parent 7c5c671045
commit 45db00824c
3 changed files with 14 additions and 9 deletions

View File

@ -6,18 +6,19 @@ import os
import time import time
import random import random
import subprocess import subprocess
from secrets import token_urlsafe
from threading import Thread from threading import Thread
from secrets import token_urlsafe
from flask import Flask, request, send_from_directory, session from flask import Flask, request, send_from_directory, session
from structures import clients, Client, NoMoreJobAvailableError, TryLaterError, Training from structures import (Client, NoMoreJobAvailableError, Training,
TryLaterError, clients)
# Définitions de variables # Définitions de variables
DATASET = "mnist-train" DATASET = "mnist-train"
TEST_SET = "mnist-t10k" TEST_SET = "mnist-t10k"
SECRET = str(random.randint(1000, 10000)) SECRET = str(random.randint(1000, 10000))
CACHE = ".cache" # À remplacer avec un chemin absolu CACHE = "/tmp/parallel/app_cache" # À remplacer avec un chemin absolu
BATCHS = 10 BATCHS = 10
RESEAU = os.path.join(CACHE, "reseau.bin") RESEAU = os.path.join(CACHE, "reseau.bin")
@ -28,13 +29,13 @@ os.makedirs(CACHE, exist_ok=True)
if not os.path.isfile(RESEAU): if not os.path.isfile(RESEAU):
if not os.path.isfile("out/main"): if not os.path.isfile("out/main"):
subprocess.call(["./make.sh", "build", "main"]) subprocess.call(["./make.sh", "build", "main"])
subprocess.call subprocess.call(
([ [
"out/main", "train", "out/main", "train",
"--epochs", "0", "--epochs", "0",
"--images", "data/mnist/train-images-idx3-ubyte", "--images", "data/mnist/train-images-idx3-ubyte",
"--labels", "data/mnist/train-labels-idx1-ubyte", "--labels", "data/mnist/train-labels-idx1-ubyte",
"--out", RESEAU, "--out", RESEAU
]) ])
print(f" * Created {RESEAU}") print(f" * Created {RESEAU}")
else: else:

View File

@ -12,7 +12,7 @@ import psutil
import requests import requests
# Définition de constantes # Définition de constantes
CACHE = ".cache" # Replace with an absolute path CACHE = "/tmp/parallel/client_cache" # Replace with an absolute path
DELTA = os.path.join(CACHE, "delta_shared.bin") DELTA = os.path.join(CACHE, "delta_shared.bin")
RESEAU = os.path.join(CACHE, "reseau_shared.bin") RESEAU = os.path.join(CACHE, "reseau_shared.bin")
SECRET = input("SECRET : ") SECRET = input("SECRET : ")

View File

@ -3,6 +3,7 @@
Description des structures. Description des structures.
""" """
import os import os
import sys
import time import time
import subprocess import subprocess
@ -101,6 +102,9 @@ class Training:
]) ])
self.cur_batch += 1 self.cur_batch += 1
self.cur_image = 0 self.cur_image = 0
if self.cur_batch >= self.batchs:
print("Done.")
sys.exit()
def patch(self): def patch(self):
@ -116,8 +120,8 @@ class Training:
if not os.path.isfile("out/main"): if not os.path.isfile("out/main"):
subprocess.call(["./make.sh", "build", "utils"]) subprocess.call(["./make.sh", "build", "utils"])
subprocess.call subprocess.call(
([ [
"out/utils", "patch-network", "out/utils", "patch-network",
"--network", self.reseau, "--network", self.reseau,
"--delta", self.delta, "--delta", self.delta,