Skip to content

Commit

Permalink
revert device_id -> device
Browse files Browse the repository at this point in the history
  • Loading branch information
bagustris committed May 27, 2024
1 parent acc4516 commit b2c8bd4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
6 changes: 2 additions & 4 deletions ini_file.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,8 @@
* batch_size = 8
* **num_workers**: Number of parallel processes for neural nets
* num_workers = 5
* **device**: For torch/huggingface models: select your GPU if you have one. Values are either "cpu" or "cuda".
* device = cpu
* **device_ids**: For torch/huggingface models: select your GPU if you have multiple. Values are GPU ids (0, 1 or both "0,1").
* device_id = 0
* **device**: For torch/huggingface models: select your GPU if you have one. Values are either "cpu" or GPU ids (e.g., 0, 1 or both "0,1"). By default, the GPU/CUDA is used if available, otherwise is CPU.
* device = 0
* **patience**: Number of epochs to wait if the result gets better (for early stopping)
* patience = 5
* **pretrained_model**: Base model for finetuning/transfer learning. Variants of wav2vec2, Hubert, and WavLM are tested to work. Default is facebook/wav2vec2-large-robust-ft-swbd-300h.
Expand Down
13 changes: 6 additions & 7 deletions nkululeko/models/model_tuned.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
Wav2Vec2PreTrainedModel,
)

from transformers import AutoConfig, AutoModel

import nkululeko.glob_conf as glob_conf
from nkululeko.models.model import Model as BaseModel
from nkululeko.reporting.reporter import Reporter
Expand All @@ -43,24 +41,25 @@ def __init__(self, df_train, df_test, feats_train, feats_test):
# device = self.util.config_val("MODEL", "device", "cpu")
self.device = "cuda" if torch.cuda.is_available() else "cpu"
self.batch_size = int(self.util.config_val("MODEL", "batch_size", "8"))
self.device_id = self.util.config_val("MODEL", "device_id", "0")
# self.device_id = self.util.config_val("MODEL", "device_id", "0")
if self.device != "cpu":
self.util.debug(f"running on device {self.device}")
os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID"
os.environ["CUDA_VISIBLE_DEVICES"] = self.device_id # self.device
os.environ["CUDA_VISIBLE_DEVICES"] = self.device # self.device
self.df_train, self.df_test = df_train, df_test
self.epoch_num = int(self.util.config_val("EXP", "epochs", 1))

self._init_model()

def _init_model(self):
model_path = "facebook/wav2vec2-large-robust-ft-swbd-300h"
pretrained_model = self.util.config_val("MODEL", "pretrained_model", model_path)
pretrained_model = self.util.config_val(
"MODEL", "pretrained_model", model_path)
self.num_layers = None
self.sampling_rate = 16000
self.max_duration_sec = 8.0
self.accumulation_steps = 4

# print finetuning information via debug
self.util.debug(f"Finetuning from model: {pretrained_model}")

Expand Down Expand Up @@ -382,7 +381,7 @@ def __init__(self, config):
setattr(config, 'add_adapter', False)

super().__init__(config)

self.wav2vec2 = Wav2Vec2Model(config)
self.cat = ModelHead(config)
self.init_weights()
Expand Down

0 comments on commit b2c8bd4

Please sign in to comment.